Browse Source

besseres Text rendering System, welches verschiedene Zeichenarten (wie zum beispiel italic oder bold) einer Schrift theoretisch ermöglich (auch wenn sie noch nicht implementiert wurden).

kolja 5 years ago
parent
commit
308722f462
14 changed files with 840 additions and 1197 deletions
  1. 20 12
      AuswahlBox.cpp
  2. 5 1
      AuswahlBox.h
  3. 0 3
      DateiSystem.cpp
  4. 54 48
      Diagramm.cpp
  5. 9 2
      Diagramm.h
  6. 21 14
      Fortschritt.cpp
  7. 5 1
      Fortschritt.h
  8. 32 28
      Knopf.cpp
  9. 5 1
      Knopf.h
  10. 527 847
      Schrift.cpp
  11. 87 177
      Schrift.h
  12. 62 58
      TextFeld.cpp
  13. 11 1
      TextFeld.h
  14. 2 4
      ToolTip.cpp

+ 20 - 12
AuswahlBox.cpp

@@ -17,7 +17,7 @@ using namespace Framework;
 // Konstruktor 
 AuswahlBox::AuswahlBox()
     : ZeichnungHintergrund(),
-    schrift( 0 ),
+    textRd( 0 ),
     msStyle( 0 ),
     members( new RCArray< TextFeld >() ),
     ausfahren( new Knopf() ),
@@ -76,8 +76,8 @@ AuswahlBox::AuswahlBox()
 // Destruktor 
 AuswahlBox::~AuswahlBox()
 {
-    if( schrift )
-        schrift->release();
+    if( textRd )
+        textRd->release();
     if( msStyle )
         msStyle->release();
     if( members )
@@ -127,18 +127,26 @@ void AuswahlBox::setEventAktion( std::function< void( void *, AuswahlBox *, int,
 
 void AuswahlBox::setSchriftZ( Schrift *schrift ) // setzt die schrift
 {
-    if( this->schrift )
-        this->schrift->release();
-    this->schrift = schrift;
+    if( !this->textRd )
+        textRd = new TextRenderer( schrift );
+    else
+        textRd->setSchriftZ( schrift );
     ausfahren->setSchriftZ( schrift->getThis() );
     rend = 1;
 }
 
+void AuswahlBox::setTextRendererZ( TextRenderer *textRd )
+{
+    if( this->textRd )
+        this->textRd->release();
+    this->textRd = textRd;
+}
+
 void AuswahlBox::addEintrag( const char *txt ) // Eintrag hinzufügen
 {
     TextFeld *tf = new TextFeld();
-    if( schrift )
-        tf->setSchriftZ( schrift->getThis() );
+    if( textRd )
+        tf->setSchriftZ( textRd->getSchrift() );
     tf->addStyle( TextFeld::Style::Sichtbar | TextFeld::Style::Center | TextFeld::Style::Rahmen );
     tf->setText( txt );
     tf->setSchriftFarbe( 0xFFFFFFFF );
@@ -152,8 +160,8 @@ void AuswahlBox::addEintrag( const char *txt ) // Eintrag hinzuf
 void AuswahlBox::addEintrag( Text *txt )
 {
     TextFeld *tf = new TextFeld();
-    if( schrift )
-        tf->setSchriftZ( schrift->getThis() );
+    if( textRd )
+        tf->setSchriftZ( textRd->getSchrift() );
     tf->addStyle( TextFeld::Style::Sichtbar | TextFeld::Style::Center | TextFeld::Style::Rahmen );
     tf->setText( txt );
     tf->setSchriftFarbe( 0xFFFFFFFF );
@@ -2134,8 +2142,8 @@ Zeichnung *AuswahlBox::dublizieren() const // Erzeugt eine Kopie des Zeichnungs
     if( toolTip )
         obj->setToolTipText( toolTip->zText()->getText(), toolTip->zBildschirm() );
     obj->setStyle( style );
-    if( schrift )
-        obj->setSchriftZ( schrift->getThis() );
+    if( textRd )
+        obj->setTextRendererZ( textRd->getThis() );
     if( rahmen )
         obj->setRahmenZ( (Rahmen*)rahmen->dublizieren() );
     if( ausfahren )

+ 5 - 1
AuswahlBox.h

@@ -13,6 +13,7 @@ namespace Framework
     class AlphaFeld; // AlphaFeld.h
     class Text; // Tet.h
     class Schrift; // Schrift.h
+    class TextRenderer;
 
     // Eine Zeichnung des 2D GUI Frameworks. Repräsentiert eine Box, aus der der Nutzer durch ausklappen verschiedene Werte auswählen kann
     class AuswahlBox : public ZeichnungHintergrund
@@ -44,7 +45,7 @@ namespace Framework
             const static __int64 Normal = Sichtbar | Erlaubt | Rahmen | FeldRahmen | AuswahlBuffer | AuswahlRahmen | MaxHeight | VScroll | MausRahmen | MausBuffer; // Normaler Style: Sichtbar, Erlaubt, Rahmen, FeldRahmen, AuswahlBuffer, AuswahlRahmen, MaxHöhe, VScroll, MausRahmen, MausBuffer
         };
     private:
-        Schrift *schrift;
+        TextRenderer *textRd;
         Array< __int64 > *msStyle;
         RCArray< TextFeld > *members;
         Knopf *ausfahren;
@@ -88,6 +89,9 @@ namespace Framework
         // Setzt die Rückruffunktion, die Aufgerufen wird, wenn der Benutzer ein neues Element auswählt
         //  eAk: Die Rückruffunktion
         __declspec( dllexport ) void setEventAktion( std::function< void( void *, AuswahlBox *, int, int ) > event );
+        // Setzt den verwendeten TextRenderer
+        //  textRd: Der Textrenderer
+        __declspec( dllexport ) void setTextRendererZ( TextRenderer *textRd );
         // Setzt die verwendete Schrift
         //  schrift: Die Schrift
         __declspec( dllexport ) void setSchriftZ( Schrift *schrift );

+ 0 - 3
DateiSystem.cpp

@@ -2954,7 +2954,6 @@ Schrift *LTDSDatei::ladeSchrift() // gibt die geladene Schrift zur
         sgKpf->laden( inF );
         Alphabet *alphabet = new Alphabet();
         alphabet->setSchriftSize( sgKpf->getSchriftGröße() );
-        alphabet->setDrawSchriftSize( sgKpf->getSchriftGröße() );
         for( int i1 = 0; i1 < sgKpf->getZeichenAnzahl(); ++i1 )
         {
             LTDSBuchstabenKopf *zeichKpf = new LTDSBuchstabenKopf();
@@ -2995,7 +2994,6 @@ Alphabet *LTDSDatei::ladeAlphabet( int schriftgr
     ret = new Alphabet();
     ret->NeuAlphabet();
     ret->setSchriftSize( schriftgröße );
-    ret->setDrawSchriftSize( schriftgröße );
     std::ifstream *inF = new std::ifstream( pfad->getText(), std::ios::binary );
     inF->seekg( dateiKopf->getPositionList()[ sgNum ], std::ios::beg );
     LTDSSchriftKopf *sgKpf = new LTDSSchriftKopf();
@@ -3064,7 +3062,6 @@ Buchstabe *LTDSDatei::ladeBuchstabe( int schriftgr
     if( ret )
     {
         ret->setSchriftSize( schriftgröße );
-        ret->setDrawSchriftSize( schriftgröße );
     }
     return ret;
 }

+ 54 - 48
Diagramm.cpp

@@ -21,7 +21,7 @@ SLDiag::SLDiag()
     ph( new RCArray< Array< int > >() ),
     pb( new RCArray< Array< int > >() ),
     lastValue( new Array< int >() ),
-    schrift( 0 ),
+    textRd( 0 ),
     gitterGr( 0, 0 ),
     lines( 0 ),
     ref( 1 )
@@ -37,16 +37,24 @@ SLDiag::~SLDiag()
     ph->release();
     pb->release();
     lastValue->release();
-    if( schrift )
-        schrift->release();
+    if( textRd )
+        textRd->release();
 }
 
 // nicht constant 
+void SLDiag::setTextRendererZ( TextRenderer *textRd )
+{
+    if( this->textRd )
+        this->textRd->release();
+    this->textRd = textRd;
+}
+
 void SLDiag::setSchriftZ( Schrift *schrift ) // setzt die Schrift
 {
-    if( this->schrift )
-        this->schrift->release();
-    this->schrift = schrift;
+    if( !this->textRd )
+        textRd = new TextRenderer( schrift );
+    else
+        textRd->setSchriftZ( schrift );
     rend = 1;
 }
 
@@ -167,14 +175,13 @@ void SLDiag::render( Bild &zRObj ) // zeichnet nach zRObj
             Text *n_tmp = lName->z( i );
             Array< int > *ph_tmp = ph->z( i );
             Array< int > *pb_tmp = pb->z( i );
-            if( hatStyle( Style::LinienName ) && schrift && n_tmp )
+            if( hatStyle( Style::LinienName ) && textRd && n_tmp )
             {
-                schrift->setSchriftSize( 12 );
-                schrift->setDrawPosition( 5, 5 + 15 * i );
+                textRd->setSchriftSize( 12 );
                 Text rtxt = n_tmp->getText();
                 rtxt += ": ";
                 rtxt += lastValue->get( i );
-                schrift->renderText( &rtxt, zRObj, f_tmp );
+                textRd->renderText( 5, 5 + 15 * i, rtxt, zRObj, f_tmp );
             }
             if( ph_tmp && pb_tmp )
             {
@@ -209,14 +216,14 @@ void SLDiag::render( Bild &zRObj ) // zeichnet nach zRObj
 // constant
 Schrift *SLDiag::getSchrift() const // gibt die Schrift zurück
 {
-    if( schrift )
-        return schrift->getThis();
+    if( textRd )
+        return textRd->getSchrift();
     return 0;
 }
 
 Schrift *SLDiag::zSchrift() const
 {
-    return schrift;
+    return textRd ? textRd->zSchrift() : 0;
 }
 
 const Punkt &SLDiag::getGSize() const // gibt die Gitter Größe zurück
@@ -1301,7 +1308,7 @@ BaseDiag *BaseDiag::release()
 LDiag::LDiag()
     : ZeichnungHintergrund(),
     BaseDiag( &cs ),
-    schrift( 0 ),
+    textRd( 0 ),
     dRam( new LRahmen() ),
     dBgF( 0 ),
     dBgB( 0 ),
@@ -1317,8 +1324,8 @@ LDiag::LDiag()
 // Destruktor
 LDiag::~LDiag()
 {
-    if( schrift )
-        schrift->release();
+    if( textRd )
+        textRd->release();
     if( dRam )
         dRam->release();
     if( dBgB )
@@ -1332,12 +1339,22 @@ LDiag::~LDiag()
 }
 
 // nicht constant
+void LDiag::setTextRendererZ( TextRenderer *textRd )
+{
+    lockZeichnung();
+    if( this->textRd )
+        this->textRd->release();
+    this->textRd = textRd;
+    unlockZeichnung();
+}
+
 void LDiag::setSchriftZ( Schrift *schrift ) // Setzt die Schrift
 {
     lockZeichnung();
-    if( this->schrift )
-        this->schrift->release();
-    this->schrift = schrift;
+    if( !this->textRd )
+        textRd = new TextRenderer( schrift );
+    else
+        textRd->setSchriftZ( schrift );
     rend = 1;
     unlockZeichnung();
 }
@@ -1584,7 +1601,7 @@ void LDiag::render( Bild &zRObj )
         if( hatDatenStyle( DiagDaten::Style::AutoRasterBreite ) )
             daten->rasterBreite = daten->hIntervallBreite;
     }
-    if( hatDatenStyle( DiagDaten::Style::VIntervall ) && schrift && schriftGr && daten )
+    if( hatDatenStyle( DiagDaten::Style::VIntervall ) && textRd && schriftGr && daten )
     { // Rendern des vertikalen Intervalls
         int vIRBbr = innenSize.y;
         if( hatDatenStyle( DiagDaten::Style::HIntervall ) && daten->hIntervallFarbe )
@@ -1595,8 +1612,7 @@ void LDiag::render( Bild &zRObj )
                 vIntervallRB->neuBild( vIRBbr, schriftGr + 2, 0xFF000000 );
             else
                 vIntervallRB->fillRegion( 0, 0, vIRBbr, schriftGr + 2, 0xFF000000 );
-            schrift->lock();
-            schrift->setSchriftSize( schriftGr );
+            textRd->setSchriftSize( schriftGr );
             if( daten->vIntervallWerte )
             {
                 int *rf = new int[ vIAnz ];
@@ -1638,13 +1654,12 @@ void LDiag::render( Bild &zRObj )
                     xPos = ( vertikalScrollBar && hatStyle( Style::VScroll ) ? vertikalScrollBar->getScroll() : vIntervallRB->getBreite() ) - xPos;
                     if( vertikalScrollBar && hatStyle( Style::VScroll ) )
                         xPos -= vertikalScrollBar->getScroll();
-                    int br = schrift->getTextBreite( &txt );
+                    int br = textRd->getTextBreite( txt );
                     if( xPos + br > vIntervallRB->getBreite() && vIntervallRB->getBreite() - br >= rWeite + 10 )
                         xPos = vIntervallRB->getBreite() - br;
                     if( xPos >= rWeite + 10 )
                     {
-                        schrift->setDrawPosition( xPos, 1 );
-                        schrift->renderText( &txt, *vIntervallRB, daten->vIntervallFarbe );
+                        textRd->renderText( xPos, 1, txt, *vIntervallRB, daten->vIntervallFarbe );
                         rWeite = xPos + br + 10;
                     }
                 }
@@ -1652,13 +1667,11 @@ void LDiag::render( Bild &zRObj )
             }
             if( daten->vIntervallName )
             {
-                int vinbr = schrift->getTextBreite( daten->vIntervallName );
+                int vinbr = textRd->getTextBreite( daten->vIntervallName->getText() );
                 int vinx = vIntervallRB->getBreite() / 2 - vinbr / 2;
                 vIntervallRB->fillRegion( vinx - 5, 1, vinbr + 10, schriftGr, 0xFF000000 );
-                schrift->setDrawPosition( vinx, 1 );
-                schrift->renderText( daten->vIntervallName, *vIntervallRB, daten->vIntervallFarbe );
+                textRd->renderText( vinx, 1, daten->vIntervallName->getText(), *vIntervallRB, daten->vIntervallFarbe );
             }
-            schrift->unlock();
             if( hatDatenStyle( DiagDaten::Style::HIntervall ) && daten->hIntervallFarbe )
                 zRObj.alphaBild90( innenSize.x - vIntervallRB->getHeight(), schriftGr + 2, vIntervallRB->getBreite(), vIntervallRB->getHeight(), *vIntervallRB );
             else
@@ -1666,7 +1679,7 @@ void LDiag::render( Bild &zRObj )
             dgbr -= vIntervallRB->getHeight();
         }
     }
-    if( hatDatenStyle( DiagDaten::Style::HIntervall ) && schrift && schriftGr && daten )
+    if( hatDatenStyle( DiagDaten::Style::HIntervall ) && textRd && schriftGr && daten )
     { // Rendern des horizontalen Intervalls
         int hIRBbr = innenSize.x;
         if( hatDatenStyle( DiagDaten::Style::VIntervall ) && daten->vIntervallFarbe )
@@ -1677,8 +1690,7 @@ void LDiag::render( Bild &zRObj )
                 hIntervallRB->neuBild( hIRBbr, schriftGr + 2, 0xFF000000 );
             else
                 hIntervallRB->fillRegion( 0, 0, hIRBbr, schriftGr + 2, 0xFF000000 );
-            schrift->lock();
-            schrift->setSchriftSize( schriftGr );
+            textRd->setSchriftSize( schriftGr );
             if( daten->hIntervallWerte )
             {
                 int *rf = new int[ hIAnz ];
@@ -1719,13 +1731,12 @@ void LDiag::render( Bild &zRObj )
                     xPos = (int)( daten->hIntervallWerte->get( rf[ i ] ) * daten->hIntervallBreite );
                     if( horizontalScrollBar && hatStyle( Style::HScroll ) )
                         xPos -= horizontalScrollBar->getScroll();
-                    int br = schrift->getTextBreite( &txt );
+                    int br = textRd->getTextBreite( txt );
                     if( xPos + br > hIntervallRB->getBreite() && hIntervallRB->getBreite() - br >= rWeite + 10 )
                         xPos = hIntervallRB->getBreite() - br;
                     if( xPos >= rWeite + 10 )
                     {
-                        schrift->setDrawPosition( xPos, 1 );
-                        schrift->renderText( &txt, *hIntervallRB, daten->hIntervallFarbe );
+                        textRd->renderText( xPos, 1, txt, *hIntervallRB, daten->hIntervallFarbe );
                         rWeite = xPos + br + 10;
                     }
                 }
@@ -1733,13 +1744,11 @@ void LDiag::render( Bild &zRObj )
             }
             if( daten->hIntervallName )
             {
-                int hinbr = schrift->getTextBreite( daten->hIntervallName );
+                int hinbr = textRd->getTextBreite( daten->hIntervallName->getText() );
                 int hinx = hIntervallRB->getBreite() / 2 - hinbr / 2;
                 hIntervallRB->fillRegion( hinx - 5, 1, hinbr + 10, schriftGr, 0xFF000000 );
-                schrift->setDrawPosition( hinx, 1 );
-                schrift->renderText( daten->hIntervallName, *hIntervallRB, daten->hIntervallFarbe );
+                textRd->renderText( hinx, 1, daten->hIntervallName->getText(), *hIntervallRB, daten->hIntervallFarbe );
             }
-            schrift->unlock();
             zRObj.alphaBild( 0, 0, hIntervallRB->getBreite(), hIntervallRB->getHeight(), *hIntervallRB );
             dghi -= hIntervallRB->getHeight();
             dgy += hIntervallRB->getHeight();
@@ -1916,26 +1925,23 @@ void LDiag::render( Bild &zRObj )
             }
         }
     }
-    if( daten && daten->werte && daten->werte->getEintragAnzahl() && schrift && schriftGr )
+    if( daten && daten->werte && daten->werte->getEintragAnzahl() && textRd && schriftGr )
     {
         int wAnz = daten->werte->getEintragAnzahl();
         int rx = 5;
         int ry = 5;
-        schrift->lock();
-        schrift->setSchriftSize( schriftGr );
+        textRd->setSchriftSize( schriftGr );
         for( int i = 0; i < wAnz; ++i )
         {
             DiagWert *w = daten->werte->z( i );
             if( w && w->name && hatWertStyle( i, DiagWert::Style::Name ) && hatWertStyle( i, DiagWert::Style::Sichtbar ) )
             {
-                int br = schrift->getTextBreite( w->name );
+                int br = textRd->getTextBreite( w->name->getText() );
                 zRObj.alphaRegion( rx, ry, br, schriftGr, 0xA0000000 );
-                schrift->setDrawPosition( rx, ry );
-                schrift->renderText( w->name, zRObj, w->farbe );
+                textRd->renderText( rx, ry, w->name->getText(), zRObj, w->farbe );
                 ry += 15;
             }
         }
-        schrift->unlock();
     }
     zRObj.releaseDrawOptions();
     zRObj.releaseDrawOptions();
@@ -1946,12 +1952,12 @@ void LDiag::render( Bild &zRObj )
 // constant
 Schrift *LDiag::getSchrift() const // Gibt die Schrift zurück
 {
-    return schrift ? schrift->getThis() : 0;
+    return textRd ? textRd->getSchrift() : 0;
 }
 
 Schrift *LDiag::zSchrift() const
 {
-    return schrift;
+    return textRd ? textRd->zSchrift() : 0;
 }
 
 Rahmen *LDiag::getDatenRahmen() const // Gibt den inneren Rahmen um das eigentliche Diagramm zurück

+ 9 - 2
Diagramm.h

@@ -15,6 +15,7 @@ namespace Framework
     class VScrollBar; // Scroll.h
     class SLDiag; // aus dieser Datei
     class LDiag; // aus dieser Datei
+    class TextRenderer;
 
     // Eine Zeichnung de 2D GUI Frameworks, die ein live Diagramm von werten zeichnet
     class SLDiag : public ZeichnungHintergrund
@@ -35,7 +36,7 @@ namespace Framework
         RCArray< Array< int > > *ph;
         RCArray< Array< int > > *pb;
         Array< int > *lastValue;
-        Schrift *schrift;
+        TextRenderer *textRd;
         Punkt gitterGr;
         int lines;
         int ref;
@@ -45,6 +46,9 @@ namespace Framework
         __declspec( dllexport ) SLDiag();
         // Destruktor 
         __declspec( dllexport ) virtual ~SLDiag();
+        // Setzt den verwendeten TextRenderer
+        //  textRd: Der Textrenderer
+        __declspec( dllexport ) void setTextRendererZ( TextRenderer *textRd );
         // Setzt einen Zeiger zur verwendeten Schrift
         //  schrift: Die Schrift
         __declspec( dllexport ) void setSchriftZ( Schrift *schrift );
@@ -514,7 +518,7 @@ namespace Framework
             const static __int64 normal = Hintergrund | scroll | DatenRahmen; // Vereint die Flags Hintergrund, scroll, DatenRahmen
         };
     private:
-        Schrift *schrift;
+        TextRenderer *textRd;
         Rahmen *dRam;
         int dBgF;
         Bild *dBgB;
@@ -528,6 +532,9 @@ namespace Framework
         __declspec( dllexport ) LDiag();
         // Destruktor
         __declspec( dllexport ) virtual ~LDiag();
+        // Setzt den verwendeten TextRenderer
+        //  textRd: Der Textrenderer
+        __declspec( dllexport ) void setTextRendererZ( TextRenderer *textRd );
         // Setzt die Schrift
         //  schrift: Die Schrift
         __declspec( dllexport ) void setSchriftZ( Schrift *schrift );

+ 21 - 14
Fortschritt.cpp

@@ -19,7 +19,7 @@ FBalken::FBalken()
     fBuffer( 0 ),
     fBgF( 0xFF000000 ),
     fBgBild( 0 ),
-    schrift( 0 ),
+    textRd( 0 ),
     schriftFarbe( 0 ),
     schriftSize( 0 ),
     ref( 1 )
@@ -36,8 +36,8 @@ FBalken::~FBalken()
         fBuffer->release();
     if( fBgBild )
         fBgBild->release();
-    if( schrift )
-        schrift->release();
+    if( textRd )
+        textRd->release();
 }
 
 // nicht constant 
@@ -133,11 +133,19 @@ void FBalken::setFBgBild( Bild *b ) // kopiert in das Fertig Hintergrund Bild
     rend = 1;
 }
 
+void FBalken::setTextRendererZ( TextRenderer *textRd )
+{
+    if( this->textRd )
+        this->textRd->release();
+    this->textRd = textRd;
+}
+
 void FBalken::setSchriftZ( Schrift *s ) // setzt die Schrift
 {
-    if( schrift )
-        schrift->release();
-    schrift = s;
+    if( !textRd )
+        textRd = new TextRenderer( s );
+    else
+        textRd->setSchriftZ( s );
     rend = 1;
 }
 
@@ -159,7 +167,7 @@ void FBalken::render( Bild &zRObj ) // zeichnet nach zRObj
         return;
     lockZeichnung();
     removeStyle( Style::VScroll | Style::HScroll );
-	ZeichnungHintergrund::render( zRObj );
+    ZeichnungHintergrund::render( zRObj );
     if( !zRObj.setDrawOptions( pos, gr ) )
     {
         unlockZeichnung();
@@ -218,14 +226,13 @@ void FBalken::render( Bild &zRObj ) // zeichnet nach zRObj
         fBuffer->render( zRObj );
     }
     zRObj.releaseDrawOptions();
-    if( hatStyle( Style::Prozent ) && schrift )
+    if( hatStyle( Style::Prozent ) && textRd )
     {
-        schrift->setSchriftSize( schriftSize );
+        textRd->setSchriftSize( schriftSize );
         Text txt;
         txt.append( (int)getProzent() );
         txt.append( "%" );
-        schrift->setDrawPosition( rbr + ( gr.x - rbr * 2 ) / 2 - schrift->getTextBreite( &txt ) / 2, rbr + ( gr.y - rbr * 2 ) / 2 - schrift->getTextHeight( &txt ) / 2 );
-        schrift->renderText( &txt, zRObj, schriftFarbe );
+        textRd->renderText( rbr + ( gr.x - rbr * 2 ) / 2 - textRd->getTextBreite( txt ) / 2, rbr + ( gr.y - rbr * 2 ) / 2 - textRd->getTextHeight( txt ) / 2, txt, zRObj, schriftFarbe );
     }
     zRObj.releaseDrawOptions();
     unlockZeichnung();
@@ -292,14 +299,14 @@ Bild *FBalken::zFBgBild() const
 
 Schrift *FBalken::getSchrift() const // gibt die Schrift zurück
 {
-    if( schrift )
-        return schrift->getThis();
+    if( textRd )
+        return textRd->getSchrift();
     return 0;
 }
 
 Schrift *FBalken::zSchrift() const
 {
-    return schrift;
+    return textRd ? textRd->zSchrift() : 0;
 }
 
 int FBalken::getSFarbe() const // gibt die Schrift Farbe zurück

+ 5 - 1
Fortschritt.h

@@ -10,6 +10,7 @@ namespace Framework
     class Bild; // Bild.h
     class Schrift; // Schrift.h
     class FBalken; // aus dieser Datei
+    class TextRenderer;
 
     // Eine Zeichnung des 2D GuI Frameworks, die einen Fortschrittsbalken zeichnet
     class FBalken : public ZeichnungHintergrund
@@ -40,7 +41,7 @@ namespace Framework
         AlphaFeld *fBuffer;
         int fBgF;
         Bild *fBgBild;
-        Schrift *schrift;
+        TextRenderer *textRd;
         int schriftFarbe;
         unsigned char schriftSize;
         int ref;
@@ -85,6 +86,9 @@ namespace Framework
         // Setzt das Hintergrund Bild durch kopieren, das in dem Teil des Balkens gezeichnet wird, der vom Fortschritt erfasst wurde
         //  b: Das Bild, das kopiert werden soll
         __declspec( dllexport ) void setFBgBild( Bild *b );
+        // Setzt den verwendeten TextRenderer
+        //  textRd: Der Textrenderer
+        __declspec( dllexport ) void setTextRendererZ( TextRenderer *textRd );
         // Setzt die Schrift, die verwendet wird, um die Prozentanzeige zu zeichnen
         __declspec( dllexport ) void setSchriftZ( Schrift *b );
         // Setzt die Farbe der Prozentanzeige

+ 32 - 28
Knopf.cpp

@@ -343,7 +343,7 @@ KontrollKnopf::KontrollKnopf()
     kAf( 0 ),
     kasten( 0 ),
     sKasten( 0 ),
-    schrift( 0 ),
+    textRd( 0 ),
     sF( 0xFFFFFFFF ),
     sGr( 12 ),
     ref( 1 )
@@ -372,8 +372,8 @@ KontrollKnopf::~KontrollKnopf()
         kasten->release();
     if( sKasten )
         sKasten->release();
-    if( schrift )
-        schrift->release();
+    if( textRd )
+        textRd->release();
 }
 
 // nicht constant 
@@ -427,11 +427,19 @@ void KontrollKnopf::setSText( const char *txt )
     rend = 1;
 }
 
+void KontrollKnopf::setTextRendererZ( TextRenderer *textRd )
+{
+    if( this->textRd )
+        this->textRd->release();
+    this->textRd = textRd;
+}
+
 void KontrollKnopf::setSchriftZ( Schrift *schrift ) // setzt die Schrift
 {
-    if( this->schrift )
-        this->schrift->release();
-    this->schrift = schrift;
+    if( !this->textRd )
+        textRd = new TextRenderer( schrift );
+    else
+        textRd->setSchriftZ( schrift );
     rend = 1;
 }
 
@@ -677,30 +685,28 @@ void KontrollKnopf::render( Bild &zRObj ) // zeichnet nach zRObj
         int kbr = 0;
         if( hatStyle( Style::Selected ) && sKasten )
         {
-            if( sTxt && schrift )
+            if( sTxt && textRd )
                 zRObj.drawBild( 0, ( gr.y / 2 - sKasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - sKasten->getHeight() / 2 ), innenSize.x, innenSize.y, *sKasten );
             else
                 zRObj.drawBild( gr.x / 2 - sKasten->getBreite() / 2, ( gr.y / 2 - sKasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - sKasten->getHeight() / 2 ), innenSize.x, innenSize.y, *sKasten );
             kbr = sKasten->getBreite();
-            if( sTxt && schrift )
+            if( sTxt && textRd )
             {
-                schrift->setSchriftSize( sGr );
-                schrift->setDrawPosition( kbr + 5, gr.y / 2 - schrift->getTextHeight( sTxt ) / 2 );
-                schrift->renderText( sTxt, zRObj, sF );
+                textRd->setSchriftSize( sGr );
+                textRd->renderText( kbr + 5, gr.y / 2 - textRd->getTextHeight( sTxt->getText() ) / 2, sTxt->getText(), zRObj, sF );
             }
         }
         else if( kasten )
         {
-            if( txt && schrift )
+            if( txt && textRd )
                 zRObj.drawBild( 0, ( gr.y / 2 - kasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - kasten->getHeight() / 2 ), innenSize.x, innenSize.y, *kasten );
             else
                 zRObj.drawBild( gr.x / 2 - kasten->getBreite() / 2, ( gr.y / 2 - kasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - kasten->getHeight() / 2 ), innenSize.x, innenSize.y, *kasten );
             kbr = kasten->getBreite();
-            if( txt && schrift )
+            if( txt && textRd )
             {
-                schrift->setSchriftSize( sGr );
-                schrift->setDrawPosition( kbr + 5, gr.y / 2 - schrift->getTextHeight( txt ) / 2 );
-                schrift->renderText( txt, zRObj, sF );
+                textRd->setSchriftSize( sGr );
+                textRd->renderText( kbr + 5, gr.y / 2 - textRd->getTextHeight( txt->getText() ) / 2, txt->getText(), zRObj, sF );
             }
         }
     }
@@ -728,17 +734,16 @@ void KontrollKnopf::render( Bild &zRObj ) // zeichnet nach zRObj
         int kbr = 0;
         if( sKasten )
         {
-            if( sTxt && schrift )
+            if( sTxt && textRd )
                 zRObj.drawBild( 0, ( gr.y / 2 - sKasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - sKasten->getHeight() / 2 ), innenSize.x, innenSize.y, *sKasten );
             else
                 zRObj.drawBild( gr.x / 2 - sKasten->getBreite() / 2, ( gr.y / 2 - sKasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - sKasten->getHeight() / 2 ), innenSize.x, innenSize.y, *sKasten );
             kbr = sKasten->getBreite();
         }
-        if( sTxt && schrift )
+        if( sTxt && textRd )
         {
-            schrift->setSchriftSize( sGr );
-            schrift->setDrawPosition( kbr + 5, gr.y / 2 - schrift->getTextHeight( sTxt ) / 2 );
-            schrift->renderText( sTxt, zRObj, sF );
+            textRd->setSchriftSize( sGr );
+            textRd->renderText( kbr + 5, gr.y / 2 - textRd->getTextHeight( sTxt->getText() ) / 2, sTxt->getText(), zRObj, sF );
         }
     }
     else
@@ -746,17 +751,16 @@ void KontrollKnopf::render( Bild &zRObj ) // zeichnet nach zRObj
         int kbr = 0;
         if( kasten )
         {
-            if( txt && schrift )
+            if( txt && textRd )
                 zRObj.drawBild( 0, ( gr.y / 2 - kasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - kasten->getHeight() / 2 ), innenSize.x, innenSize.y, *kasten );
             else
                 zRObj.drawBild( gr.x / 2 - kasten->getBreite() / 2, ( gr.y / 2 - kasten->getHeight() / 2 ) < 0 ? 0 : ( gr.y / 2 - kasten->getHeight() / 2 ), innenSize.x, innenSize.y, *kasten );
             kbr = kasten->getBreite();
         }
-        if( txt && schrift )
+        if( txt && textRd )
         {
-            schrift->setSchriftSize( sGr );
-            schrift->setDrawPosition( kbr + 5, gr.y / 2 - schrift->getTextHeight( txt ) / 2 );
-            schrift->renderText( txt, zRObj, sF );
+            textRd->setSchriftSize( sGr );
+            textRd->renderText( kbr + 5, gr.y / 2 - textRd->getTextHeight( txt->getText() ) / 2, txt->getText(), zRObj, sF );
         }
     }
     zRObj.releaseDrawOptions();
@@ -786,12 +790,12 @@ Text *KontrollKnopf::zSText() const
 
 Schrift *KontrollKnopf::getSchrift() const // gibt die Schrift zurück
 {
-    return schrift ? schrift->getThis() : 0;
+    return textRd ? textRd->getSchrift() : 0;
 }
 
 Schrift *KontrollKnopf::zSchrift() const
 {
-    return schrift;
+    return textRd ? textRd->zSchrift() : 0;
 }
 
 int KontrollKnopf::getSFarbe() const // gibt die Schrift Farbe zurück

+ 5 - 1
Knopf.h

@@ -13,6 +13,7 @@ namespace Framework
     class LTDBDatei; // Dateisystem.h
     class Knopf; // aus dieser Datei
     class KontrollKnopf; // aus dieser Datei
+    class TextRenderer;
 
     // Eine Zeichnung des 2D GUI Frameworks, die einen Knopf zeichnet, den der Benutzer drücken kann
     class Knopf : public TextFeld
@@ -127,7 +128,7 @@ namespace Framework
         AlphaFeld *kAf;
         Bild *kasten;
         Bild *sKasten;
-        Schrift *schrift;
+        TextRenderer *textRd;
         int sF;
         int sGr;
         int ref;
@@ -155,6 +156,9 @@ namespace Framework
         // Setzt den Beschriftungs Text, der angezeigt wird, während das Kästchen ausgewählt ist
         //  txt: Der Text
         __declspec( dllexport ) void setSText( const char *txt );
+        // Setzt den verwendeten TextRenderer
+        //  textRd: Der Textrenderer
+        __declspec( dllexport ) void setTextRendererZ( TextRenderer *textRd );
         // Setzt die Schrift, die für die Beschriftung verwendet werden soll
         //  schrift: Die Schrift
         __declspec( dllexport ) void setSchriftZ( Schrift *schrift );

+ 527 - 847
Schrift.cpp

@@ -14,10 +14,8 @@ using namespace Framework;
 // Konstruktor 
 Buchstabe::Buchstabe()
     : size( 0, 0 ),
-    pos( 0, 0 ),
     alpha( 0 ),
     schriftSize( 0 ),
-    drawSg( 0 ),
     ref( 1 )
 {}
 
@@ -53,25 +51,14 @@ void Buchstabe::setPixel( int i, unsigned char alpha )
     this->alpha[ i ] = alpha;
 }
 
-void Buchstabe::setPosition( Punkt &pos ) // setzt die Buchstabenposition
-{
-    this->pos = pos;
-}
-
-void Buchstabe::setPosition( int x, int y )
-{
-    pos.x = x;
-    pos.y = y;
-}
-
 void Buchstabe::setSchriftSize( int sg ) // setzt die Schriftgröße des Buchstaben
 {
     schriftSize = sg;
 }
 
-void Buchstabe::setDrawSchriftSize( int dsg ) // setzt die Zeichengröße des Buchstaben
+int Buchstabe::getSchriftSize() const
 {
-    drawSg = dsg;
+    return schriftSize;
 }
 
 // constant
@@ -82,15 +69,10 @@ const Punkt &Buchstabe::getSize() const // gibt die Buchstabenbildgr
 
 int Buchstabe::getBreite() const // Buchstabenbreite
 {
-    return (int)( ( (double)size.x / (double)schriftSize ) * (double)drawSg + 0.5 );
+    return size.x;
 }
 
 int Buchstabe::getHeight() const // Buchstabenhöhe
-{
-    return (int)( ( (double)size.y / (double)schriftSize ) *(double)drawSg + 0.5 );
-}
-
-int Buchstabe::getNormHeight() const // Buchstabenhöhe
 {
     return size.y;
 }
@@ -100,97 +82,6 @@ unsigned char *Buchstabe::getBuff() const // gibt den Alphabuffer zur
     return alpha;
 }
 
-void Buchstabe::render( Bild &zRObj, int f ) const // Zeichnet nach zRObj
-{
-    if( alpha )
-    {
-        const Punkt &zRObjGr = zRObj.getDrawGr();
-        const Punkt &zRObjPos = zRObj.getDrawPos();
-        const Punkt &zRObjOff = zRObj.getDrawOff();
-        int xp = pos.x + zRObjOff.x, yp = pos.y + zRObjOff.y;
-        int xs = xp < zRObjPos.x ? ( zRObjPos.x - xp ) : 0, ys = yp < zRObjPos.y ? ( zRObjPos.y - yp ) : 0;
-        int b = size.x, h = size.y;
-        unsigned char a2 = (unsigned char)( 255 - ( f >> 24 ) );
-        f &= 0x00FFFFFF;
-        if( schriftSize == drawSg )
-        {
-            if( xp >= zRObjGr.x || yp >= zRObjGr.y || xp + b < zRObjPos.x || yp + h < zRObjPos.y )
-                return;
-            b = ( xp + b ) > zRObjGr.x ? ( zRObjGr.x - xp ) : b;
-            h = ( yp + h ) > zRObjGr.y ? ( zRObjGr.y - yp ) : h;
-            if( !a2 )
-            {
-                int xx, ygr = ( ys - 1 ) * size.x, ygr2 = ( yp + ys - 1 ) * zRObj.getBreite();
-                for( int yy = ys; yy < h; ++yy )
-                {
-                    ygr += size.x;
-                    ygr2 += zRObj.getBreite();
-                    for( xx = xs; xx < b; ++xx )
-                        zRObj.alphaPixel( xp + xx + ygr2, f | ( alpha[ xx + ygr ] << 24 ) );
-                }
-            }
-            else
-            {
-                int a;
-                int xx, ygr = ( ys - 1 ) * size.x, ygr2 = ( yp + ys - 1 ) * zRObj.getBreite();
-                for( int yy = ys; yy < h; ++yy )
-                {
-                    ygr += size.x;
-                    ygr2 += zRObj.getBreite();
-                    for( xx = xs; xx < b; ++xx )
-                    {
-                        a = alpha[ xx + ygr ] - a2;
-                        if( a > 0 )
-                            zRObj.alphaPixel( xp + xx + ygr2, f | ( a << 24 ) );
-                    }
-                }
-            }
-        }
-        else
-        {
-            double xoff = (double)schriftSize / (double)drawSg,
-                yoff = (double)schriftSize / (double)drawSg;
-            double x = xs * xoff, y = ys * yoff;
-            int maxX = getBreite(), maxY = getHeight();
-            maxX = ( xp + maxX ) >= zRObjGr.x ? ( zRObjGr.x - xp ) : maxX;
-            maxY = ( yp + maxY ) >= zRObjGr.y ? ( zRObjGr.y - yp ) : maxY;
-            if( !a2 )
-            {
-                int dx, ygr, ygr2;
-                for( int dy = ys; dy < maxY; ++dy )
-                {
-                    ygr2 = ( yp + dy ) * zRObj.getBreite();
-                    ygr = (int)y * b;
-                    for( dx = xs; dx < maxX; ++dx )
-                    {
-                        zRObj.alphaPixel( xp + dx + ygr2, f | ( alpha[ (int)x + ygr ] << 24 ) );
-                        x += xoff;
-                    }
-                    x = xs;
-                    y += yoff;
-                }
-            }
-            else
-            {
-                int a, dx, ygr, ygr2;
-                for( int dy = ys; dy < maxY; ++dy )
-                {
-                    ygr2 = ( yp + dy ) * zRObj.getBreite();
-                    ygr = (int)y * b;
-                    for( dx = xs; dx < maxX; ++dx )
-                    {
-                        a = alpha[ (int)x + ygr ] - a2;
-                        zRObj.alphaPixel( xp + dx + ygr2, f | ( a << 24 ) );
-                        x += xoff;
-                    }
-                    x = xs;
-                    y += yoff;
-                }
-            }
-        }
-    }
-}
-
 // Reference Counting 
 Buchstabe *Buchstabe::getThis()
 {
@@ -206,15 +97,12 @@ Buchstabe *Buchstabe::release()
     return 0;
 }
 
+
 // Inhalt der Alphabet Klasse aus Schrift.h
 // Konstruktor 
 Alphabet::Alphabet()
     : zeichen( new Buchstabe*[ 256 ] ),
     schriftSize( 12 ),
-    drawSchriftSize( 12 ),
-    pos( 0, 0 ),
-    zeilenHeight( 0 ),
-    zeilenAbstand( 5 ),
     ref( 1 )
 {
     for( int i = 0; i < 256; ++i )
@@ -242,7 +130,6 @@ void Alphabet::NeuAlphabet() // Initialisierung
     }
     for( int i = 0; i < 256; ++i )
         zeichen[ i ] = 0;
-    zeilenHeight = 0;
 }
 
 void Alphabet::setBuchstabe( unsigned char i, Buchstabe *buchstabe ) // setzt einen Buchstaben
@@ -253,13 +140,6 @@ void Alphabet::setBuchstabe( unsigned char i, Buchstabe *buchstabe ) // setzt ei
     if( zeichen[ i ] )
     {
         zeichen[ i ]->setSchriftSize( schriftSize );
-        zeichen[ i ]->setDrawSchriftSize( drawSchriftSize );
-    }
-    zeilenHeight = 0;
-    for( int i = 0; i < 256; ++i )
-    {
-        if( zeichen[ i ] != 0 )
-            zeilenHeight = maxInt( zeichen[ i ]->getHeight(), zeilenHeight );
     }
 }
 
@@ -273,32 +153,6 @@ void Alphabet::setSchriftSize( int gr ) // setzt die Schriftgr
     }
 }
 
-void Alphabet::setDrawSchriftSize( int gr ) // setzt die Zeichengröße
-{
-    drawSchriftSize = gr;
-    for( int i = 0; i < 256; ++i )
-    {
-        if( zeichen[ i ] )
-            zeichen[ i ]->setDrawSchriftSize( gr );
-    }
-}
-
-void Alphabet::setZeilenAbstand( int za ) // setzt die Zeilenhöhe( Zeilenabstand )
-{
-    zeilenAbstand = za;
-}
-
-void Alphabet::setDrawPosition( Punkt &pos ) // setzt die Draw Position
-{
-    this->pos = pos;
-}
-
-void Alphabet::setDrawPosition( int x, int y )
-{
-    pos.x = x;
-    pos.y = y;
-}
-
 // constant 
 Buchstabe *Alphabet::getBuchstabe( unsigned char i ) const // gibt einen Buchstaben zurück
 {
@@ -322,399 +176,218 @@ int Alphabet::getSchriftSize() const // gibt die Schriftgr
     return schriftSize;
 }
 
-int Alphabet::getDrawSchriftSize() const // gibt die Zeichengröße zurück
+// Reference Counting 
+Alphabet *Alphabet::getThis()
 {
-    return drawSchriftSize;
+    ++ref;
+    return this;
 }
 
-int Alphabet::getZeilenAbstand() const // gibt den Zeilenabstand zurück
+Alphabet *Alphabet::release()
 {
-    return zeilenAbstand;
+    --ref;
+    if( ref == 0 )
+        delete this;
+    return 0;
 }
 
-int Alphabet::getZeilenHeight() const // gibt die Höhe des höchsten Zeichens zurück
-{
-    return (int)( (double)zeilenHeight / schriftSize * drawSchriftSize + 0.5 );
-}
+// Inhalt der AlphabetArray Klasse aus Schrift.h
+// Konstruktor 
+AlphabetArray::AlphabetArray()
+    : next( 0 ),
+    This( 0 )
+{}
 
-const Punkt &Alphabet::getPosition() const // gibt die DrawPosition zurück
+// Destruktor 
+AlphabetArray::~AlphabetArray()
 {
-    return pos;
+    if( This )
+        This->release();
+    delete next;
 }
 
-int Alphabet::getTextBreite( Text *zTxt ) const // gibt die Breite des Textes zurück
+// nicht constant 
+bool AlphabetArray::addAlphabet( Alphabet *alphabet ) // Fügt ein Alphabet hinzu
 {
-    int ret = 0;
-    int len = zTxt->getLength();
-    char *buff = zTxt->getText();
-    unsigned char c = 0;
-    int tmp = 0;
-    for( int i = 0; i < len; ++i )
+    if( This )
     {
-        c = (unsigned char)buff[ i ];
-        if( buff[ i ] == '\n' )
-        {
-            if( tmp > ret )
-                ret = tmp;
-            tmp = 0;
-        }
-        else if( buff[ i ] == '\r' )
+        if( This->getSchriftSize() == alphabet->getSchriftSize() )
         {
-            i += 10;
-            continue;
+            alphabet->release();
+            return false;
         }
-        else if( buff[ i ] == '\t' )
-            tmp += drawSchriftSize;
-        else if( buff[ i ] == ' ' )
-            tmp += drawSchriftSize / 2;
-        else if( zeichen[ c ] )
-            tmp += zeichen[ c ]->getBreite();
     }
-    if( tmp > ret )
-        ret = tmp;
-    return ret;
+    else
+    {
+        This = alphabet;
+        return true;
+    }
+    if( !next )
+        next = new AlphabetArray();
+    return next->addAlphabet( alphabet );
 }
 
-int Alphabet::getTextHeight( Text *zTxt ) const // gibt die Höhe des Textes zurück
+bool AlphabetArray::removeAlphabet( int sg ) // entfernt ein Alphabet
 {
-    int hi = getZeilenHeight();
-    return hi + ( ( hi + zeilenAbstand ) * zTxt->anzahlVon( '\n' ) );
+    if( This )
+    {
+        if( This->getSchriftSize() == sg )
+            This = This->release();
+        return 1;
+    }
+    if( !next )
+        return 0;
+    if( next->removeAlphabet( sg ) )
+    {
+        AlphabetArray *tmp = next->getNext();
+        next->setNext0();
+        delete next;
+        next = tmp;
+    }
+    return 0;
 }
 
-int Alphabet::textPos( Text *zText, int mausX, int mausY ) const // gibt den Buchstaben zurück, auf den die Maus zeigt
+void AlphabetArray::setNext0() // setzt den next Zeiger zu 0
 {
-    char *buffer = zText->getText();
-    int len = zText->getLength();
-    int tx = 0;
-    int ty = 0;
-    int sh = getZeilenHeight();
-    if( mausX < 0 || mausY < 0 )
-        return -1;
-    for( int i = 0; i < len; ++i )
+    next = 0;
+}
+
+// constant 
+Alphabet *AlphabetArray::getAlphabet( unsigned char sg ) const // gibt getThis von einem Alphabet zurück
+{
+    if( !This )
+        return 0;
+    if( This->getSchriftSize() == sg )
+        return This->getThis();
+    if( next )
+        return next->getAlphabet( sg );
+    return 0;
+}
+
+Alphabet *AlphabetArray::zAlphabet( unsigned char sg ) const // gibt ein Alphabet zurück
+{
+    if( !This )
+        return 0;
+    if( This->getSchriftSize() == sg )
+        return This;
+    if( next )
+        return next->zAlphabet( sg );
+    return 0;
+}
+
+Alphabet *AlphabetArray::getAlphabetI( int index, int count ) const
+{
+    if( count == index )
+        return This->getThis();
+    if( next )
+        return next->getAlphabetI( index, count + 1 );
+    return 0;
+}
+
+Alphabet *AlphabetArray::zAlphabetI( int index, int count ) const
+{
+    if( count == index )
+        return This;
+    if( next )
+        return next->zAlphabetI( index, count + 1 );
+    return 0;
+}
+
+AlphabetArray *AlphabetArray::getNext() const // gibt das nächste Alphabet zurück
+{
+    return next;
+}
+
+// Inhalt der Schrift Klasse aus Schrift.h
+// Konstruktor 
+Schrift::Schrift()
+    : alphabetAnzahl( 0 ),
+    alphabet( new AlphabetArray() ),
+    ref( 1 )
+{}
+
+// Destruktor 
+Schrift::~Schrift()
+{
+    delete alphabet;
+}
+
+bool Schrift::addAlphabet( Alphabet *alphabet ) // Fügt der Schrift ein Alphabet hinzu
+{
+    if( this->alphabet->addAlphabet( alphabet ) )
     {
-        if( buffer[ i ] == '\n' )
-        {
-            ty += sh + zeilenAbstand;
-            tx = 0;
-            if( mausY < ty )
-                return i;
-        }
-        if( buffer[ i ] == '\t' )
-            tx += drawSchriftSize;
-        if( buffer[ i ] == ' ' )
-            tx += drawSchriftSize / 2;
-        if( zeichen[ (unsigned char)buffer[ i ] ] )
-            tx += zeichen[ (unsigned char)buffer[ i ] ]->getBreite();
-        int txpl = 0;
-        if( zeichen[ (unsigned char)buffer[ i + 1 ] ] )
-            txpl = zeichen[ (unsigned char)buffer[ i + 1 ] ]->getBreite() / 2;
-        if( mausX < tx - txpl && mausY < ty + sh + zeilenAbstand )
-            return i;
+        ++alphabetAnzahl;
+        return true;
     }
-    if( mausY < ty + sh + zeilenAbstand )
-        return len;
-    return -1;
+    return false;
 }
 
-void Alphabet::textFormatieren( Text *zText, int maxBreite, int schriftSize ) // fügt zeilenumbrüche ein 
+void Schrift::removeAlphabet( int sg ) // Entfernt ein Alphabet
 {
-    int sg = drawSchriftSize;
-    setDrawSchriftSize( schriftSize );
-    int lastPos = -1;
-    int len = zText->getLength();
-    char *txt = zText->getText();
-    int x = 0;
-    Text result = zText->getText();
-    for( int i = 0; i < len; ++i )
+    if( alphabet->removeAlphabet( sg ) )
+        --alphabetAnzahl;
+}
+
+// constant 
+Alphabet *Schrift::getAlphabet( int sg ) const
+{
+    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)sg );
+    if( !drawAlphabet )
     {
-        char c = txt[ i ];
-        if( c == ' ' )
-        {
-            lastPos = i;
-            x += schriftSize / 2;
-            continue;
-        }
-        if( c == '\t' )
-        {
-            lastPos = i;
-            x += schriftSize;
-            continue;
-        }
-        if( c == '\n' )
-        {
-            x = 0;
-            lastPos = -1;
-            continue;
-        }
-        if( c == '\r' && len - i >= 11 )
-        {
-            i += 10;
-            continue;
-        }
-        Buchstabe *b = getBuchstabe( (unsigned)c );
-        if( b )
+        for( int i = 0; i < 256; ++i )
         {
-            x += b->getBreite();
-            if( x > maxBreite && lastPos > -1 )
-            {
-                result.ersetzen( lastPos, lastPos + 1, "\n" );
-                x = 0;
-                i = lastPos;
-                lastPos = -1;
-            }
-            b = b->release();
+            drawAlphabet = alphabet->zAlphabet( (unsigned char)( sg - i ) );
+            if( drawAlphabet )
+                break;
+            drawAlphabet = alphabet->zAlphabet( (unsigned char)( sg + i ) );
+            if( drawAlphabet )
+                break;
         }
     }
-    zText->setText( result );
-    setDrawSchriftSize( sg );
+    return drawAlphabet->getThis();
 }
 
-void Alphabet::render( Text *zTxt, Bild &rendezRObj, std::function< int( int, int, int ) > f ) const // Zeichnet txt nach rendezRObj
+Alphabet *Schrift::zAlphabet( int sg ) const
 {
-    int zRObjBr = rendezRObj.getBreite();
-    int zRObjHi = rendezRObj.getHeight();
-    int xp = pos.x;
-    int yp = pos.y;
-    int zh = getZeilenHeight();
-    if( yp + ( zh + zeilenAbstand ) * zTxt->anzahlVon( '\n' ) + zh < 0 || xp >= zRObjBr || yp >= zRObjHi )
-        return;
-    char *text = zTxt->getText();
-    int len = zTxt->getLength();
-    for( int i = 0; i < len; ++i )
+    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)sg );
+    if( !drawAlphabet )
     {
-        unsigned char c = text[ i ];
-        if( c == ' ' )
-        {
-            xp += drawSchriftSize / 2;
-            continue;
-        }
-        if( c == '\t' )
-        {
-            xp += drawSchriftSize;
-            continue;
-        }
-        if( c == '\n' )
-        {
-            yp += zh + zeilenAbstand;
-            xp = pos.x;
-            continue;
-        }
-        if( zeichen[ c ] )
+        for( int i = 0; i < 256; ++i )
         {
-            if( xp >= zRObjBr )
-                continue;
-            if( rendezRObj.isAreaDrawable( xp, yp, zeichen[ c ]->getBreite(), zeichen[ c ]->getHeight() ) )
-            {
-                zeichen[ c ]->setPosition( xp, yp );
-                zeichen[ c ]->render( rendezRObj, f( xp, yp, i ) );
-            }
-            xp += zeichen[ c ]->getBreite();
+            drawAlphabet = alphabet->zAlphabet( (unsigned char)( sg - i ) );
+            if( drawAlphabet )
+                break;
+            drawAlphabet = alphabet->zAlphabet( (unsigned char)( sg + i ) );
+            if( drawAlphabet )
+                break;
         }
     }
+    return drawAlphabet;
 }
 
-void Alphabet::render( Text *zTxt, Bild &rendezRObj, int f ) const // Zeichnet txt nach rendezRObj
+Alphabet *Schrift::getAlphabetI( int index ) const
 {
-    int zRObjBr = rendezRObj.getBreite();
-    int zRObjHi = rendezRObj.getHeight();
-    int xp = pos.x;
-    int yp = pos.y;
-    int zh = getZeilenHeight();
-    if( yp + ( zh + zeilenAbstand ) * zTxt->anzahlVon( '\n' ) + zh < 0 || xp >= zRObjBr || yp >= zRObjHi )
-        return;
-    char *text = zTxt->getText();
-    int len = zTxt->getLength();
-    for( int i = 0; i < len; ++i )
-    {
-        unsigned char c = text[ i ];
-        if( c == ' ' )
-        {
-            xp += drawSchriftSize / 2;
-            continue;
-        }
-        if( c == '\t' )
-        {
-            xp += drawSchriftSize;
-            continue;
-        }
-        if( c == '\n' )
-        {
-            yp += zh + zeilenAbstand;
-            xp = pos.x;
-            continue;
-        }
-        if( c == '\r' && len - i >= 11 )
-        {
-            i += 3;
-            Text *hex1 = zTxt->getTeilText( i, i + 6 );
-            Text *hex2 = zTxt->getTeilText( i + 6, i + 8 );
-            f = ( TextZuInt( hex1->getText(), 16 ) << 8 ) |
-                ( TextZuInt( hex2->getText(), 16 ) );
-            hex1->release();
-            hex2->release();
-            i += 7;
-            continue;
-        }
-        if( zeichen[ c ] )
-        {
-            if( xp >= zRObjBr )
-                continue;
-            if( rendezRObj.isAreaDrawable( xp, yp, zeichen[ c ]->getBreite(), zeichen[ c ]->getHeight() ) )
-            {
-                zeichen[ c ]->setPosition( xp, yp );
-                zeichen[ c ]->render( rendezRObj, f );
-            }
-            xp += zeichen[ c ]->getBreite();
-        }
-    }
+    return alphabet->getAlphabetI( index, 0 );
 }
 
-void Alphabet::render( Text *zTxt, Bild &rendezRObj, int cpos, int cf, int fbeg, int ff, std::function< int( int, int, int ) > f ) const
+Alphabet *Schrift::zAlphabetI( int index ) const
 {
-    int zRObjBr = rendezRObj.getBreite();
-    int zRObjHi = rendezRObj.getHeight();
-    int xp = pos.x;
-    int yp = pos.y;
-    int zh = getZeilenHeight();
-    if( yp + ( zh + zeilenAbstand ) * zTxt->anzahlVon( '\n' ) + zh < 0 || xp >= zRObjBr || yp >= zRObjHi )
-        return;
-    char *text = zTxt->getText();
-    int len = zTxt->getLength();
-    bool faerb = 0;
-    for( int i = 0; i < len; ++i )
-    {
-        unsigned char c = text[ i ];
-        if( i == fbeg )
-            faerb = !faerb;
-        if( i == cpos )
-        {
-            rendezRObj.drawLinieVAlpha( xp, yp, zh, cf );
-            faerb = !faerb;
-        }
-        if( c == ' ' )
-        {
-            if( faerb )
-                rendezRObj.alphaRegion( xp, yp, drawSchriftSize / 2, zh, ff );
-            xp += drawSchriftSize / 2;
-            continue;
-        }
-        if( c == '\t' )
-        {
-            if( faerb )
-                rendezRObj.alphaRegion( xp, yp, drawSchriftSize, zh, ff );
-            xp += drawSchriftSize;
-            continue;
-        }
-        if( c == '\n' )
-        {
-            yp += zh + zeilenAbstand;
-            xp = pos.x;
-            continue;
-        }
-        if( zeichen[ c ] )
-        {
-            if( xp >= zRObjBr )
-                continue;
-            if( rendezRObj.isAreaDrawable( xp, yp, zeichen[ c ]->getBreite(), zeichen[ c ]->getHeight() ) )
-            {
-                if( faerb )
-                {
-                    int br = zeichen[ c ]->getBreite();
-                    rendezRObj.alphaRegion( xp, yp, br, zh, ff );
-                }
-                zeichen[ c ]->setPosition( xp, yp );
-                zeichen[ c ]->render( rendezRObj, f( xp, yp, i ) );
-            }
-            xp += zeichen[ c ]->getBreite();
-        }
-    }
-    if( len == cpos )
-        rendezRObj.drawLinieVAlpha( xp, yp, zh, cf );
+    return alphabet->zAlphabetI( index, 0 );
 }
 
-void Alphabet::render( Text *zTxt, Bild &rendezRObj, int cpos, int cf, int fbeg, int ff, int f ) const
+unsigned char Schrift::getAlphabetAnzahl() const // gibt die anzahl von in der Schrift enthaltenen Alphabeten zurück
 {
-    int zRObjBr = rendezRObj.getBreite();
-    int zRObjHi = rendezRObj.getHeight();
-    int xp = pos.x;
-    int yp = pos.y;
-    int zh = getZeilenHeight();
-    if( yp + ( zh + zeilenAbstand ) * zTxt->anzahlVon( '\n' ) + zh < 0 || xp >= zRObjBr || yp >= zRObjHi )
-        return;
-    char *text = zTxt->getText();
-    int len = zTxt->getLength();
-    bool faerb = 0;
-    for( int i = 0; i < len; ++i )
-    {
-        unsigned char c = text[ i ];
-        if( i == fbeg )
-            faerb = !faerb;
-        if( i == cpos )
-        {
-            rendezRObj.drawLinieVAlpha( xp, yp, zh, cf );
-            faerb = !faerb;
-        }
-        if( c == ' ' )
-        {
-            if( faerb )
-                rendezRObj.alphaRegion( xp, yp, drawSchriftSize / 2, zh, ff );
-            xp += drawSchriftSize / 2;
-            continue;
-        }
-        if( c == '\t' )
-        {
-            if( faerb )
-                rendezRObj.alphaRegion( xp, yp, drawSchriftSize, zh, ff );
-            xp += drawSchriftSize;
-            continue;
-        }
-        if( c == '\n' )
-        {
-            yp += zh + zeilenAbstand;
-            xp = pos.x;
-            continue;
-        }
-        if( c == '\r' && len - i >= 11 )
-        {
-            i += 3;
-            Text *hex1 = zTxt->getTeilText( i, i + 6 );
-            Text *hex2 = zTxt->getTeilText( i + 6, i + 8 );
-            f = ( TextZuInt( hex1->getText(), 16 ) << 8 ) |
-                ( TextZuInt( hex2->getText(), 16 ) );
-            hex1->release();
-            hex2->release();
-            i += 7;
-            continue;
-        }
-        if( zeichen[ c ] )
-        {
-            if( xp >= zRObjBr )
-                continue;
-            if( rendezRObj.isAreaDrawable( xp, yp, zeichen[ c ]->getBreite(), zeichen[ c ]->getHeight() ) )
-            {
-                if( faerb )
-                {
-                    int br = zeichen[ c ]->getBreite();
-                    rendezRObj.alphaRegion( xp, yp, br, zh, ff );
-                }
-                zeichen[ c ]->setPosition( xp, yp );
-                zeichen[ c ]->render( rendezRObj, f );
-            }
-            xp += zeichen[ c ]->getBreite();
-        }
-    }
-    if( len == cpos )
-        rendezRObj.drawLinieVAlpha( xp, yp, zh, cf );
+    return alphabetAnzahl;
 }
 
 // Reference Counting 
-Alphabet *Alphabet::getThis()
+Schrift *Schrift::getThis()
 {
     ++ref;
     return this;
 }
 
-Alphabet *Alphabet::release()
+Schrift *Schrift::release()
 {
     --ref;
     if( ref == 0 )
@@ -722,450 +395,457 @@ Alphabet *Alphabet::release()
     return 0;
 }
 
-// Inhalt der AlphabetArray Klasse aus Schrift.h
-// Konstruktor 
-AlphabetArray::AlphabetArray()
-    : next( 0 ),
-    This( 0 )
-{}
-
-// Destruktor 
-AlphabetArray::~AlphabetArray()
-{
-    if( This )
-        This->release();
-    delete next;
-}
-
-// nicht constant 
-bool AlphabetArray::addAlphabet( Alphabet *alphabet ) // Fügt ein Alphabet hinzu
-{
-    if( This )
-    {
-        if( This->getSchriftSize() == alphabet->getSchriftSize() )
-        {
-            alphabet->release();
-            return false;
-        }
-    }
-    else
-    {
-        This = alphabet;
-        return true;
-    }
-    if( !next )
-        next = new AlphabetArray();
-    return next->addAlphabet( alphabet );
-}
-
-bool AlphabetArray::removeAlphabet( int sg ) // entfernt ein Alphabet
-{
-    if( This )
-    {
-        if( This->getSchriftSize() == sg )
-            This = This->release();
-        return 1;
-    }
-    if( !next )
-        return 0;
-    if( next->removeAlphabet( sg ) )
-    {
-        AlphabetArray *tmp = next->getNext();
-        next->setNext0();
-        delete next;
-        next = tmp;
-    }
-    return 0;
-}
-
-void AlphabetArray::setDrawSchriftSize( int sg ) // Setzt die Draw Schriftgröße aller Alphabete
-{
-    if( This )
-        This->setDrawSchriftSize( sg );
-    if( next )
-        next->setDrawSchriftSize( sg );
-}
 
-void AlphabetArray::setZeilenAbstand( int za ) // setzt den Zeilenabstant aller Alphabete
-{
-    if( This )
-        This->setZeilenAbstand( za );
-    if( next )
-        next->setZeilenAbstand( za );
-}
+TextRenderer::TextRenderer()
+    : TextRenderer( 0 )
+{}
 
-void AlphabetArray::setNext0() // setzt den next Zeiger zu 0
+TextRenderer::TextRenderer( Schrift *schrift )
 {
-    next = 0;
+    s = schrift;
+    schriftSize = 12;
+    zeilenAbstand = 5;
+    zeichenAbstand = 0;
+    ref = 1;
 }
 
-// constant 
-Alphabet *AlphabetArray::getAlphabet( unsigned char sg ) const // gibt getThis von einem Alphabet zurück
+TextRenderer::~TextRenderer()
 {
-    if( !This )
-        return 0;
-    if( This->getSchriftSize() == sg )
-        return This->getThis();
-    if( next )
-        return next->getAlphabet( sg );
-    return 0;
+    s->release();
 }
 
-Alphabet *AlphabetArray::zAlphabet( unsigned char sg ) const // gibt ein Alphabet zurück
-{
-    if( !This )
-        return 0;
-    if( This->getSchriftSize() == sg )
-        return This;
-    if( next )
-        return next->zAlphabet( sg );
-    return 0;
-}
 
-Alphabet *AlphabetArray::getAlphabetI( int index, int count ) const
+void TextRenderer::setSchriftZ( Schrift *schrift )
 {
-    if( count == index )
-        return This->getThis();
-    if( next )
-        return next->getAlphabetI( index, count + 1 );
-    return 0;
+    if( s )
+        s->release();
+    s = schrift;
 }
 
-Alphabet *AlphabetArray::zAlphabetI( int index, int count ) const
+Schrift *TextRenderer::getSchrift()
 {
-    if( count == index )
-        return This;
-    if( next )
-        return next->zAlphabetI( index, count + 1 );
+    if( s )
+        return s->getThis();
     return 0;
 }
 
-AlphabetArray *AlphabetArray::getNext() const // gibt das nächste Alphabet zurück
+Schrift *TextRenderer::zSchrift()
 {
-    return next;
+    return s;
 }
 
-// Inhalt der Schrift Klasse aus Schrift.h
-// Konstruktor 
-Schrift::Schrift()
-    : alphabetAnzahl( 0 ),
-    alphabet( new AlphabetArray() ),
-    schriftSize( 12 ),
-    zeilenAbstand( 5 ),
-    drawPos( 0, 0 ),
-    ref( 1 )
+// Setzt die Schriftgröße, in der gezeichnet werden soll. Die Schrift wählt automatisch das passende Alphabet zum Zeichnen
+//  sg: Die Schriftgröße
+void TextRenderer::setSchriftSize( int sg )
 {
-}
-
-// Destruktor 
-Schrift::~Schrift()
-{
-    delete alphabet;
-}
-
-// nicht constant 
-void Schrift::lock() // lockt die Schrift
-{
-    cs.lock();
-}
-
-void Schrift::unlock() // unlockt die Schrift
-{
-    cs.unlock();
-}
-
-bool Schrift::addAlphabet( Alphabet *alphabet ) // Fügt der Schrift ein Alphabet hinzu
-{
-    lock();
-    if( this->alphabet->addAlphabet( alphabet ) )
-    {
-        ++alphabetAnzahl;
-        alphabet->setDrawSchriftSize( schriftSize );
-        unlock();
-        return true;
-    }
-    unlock();
-    return false;
-}
-
-void Schrift::removeAlphabet( int sg ) // Entfernt ein Alphabet
-{
-    lock();
-    if( alphabet->removeAlphabet( sg ) )
-        --alphabetAnzahl;
-    unlock();
-}
-
-void Schrift::setDrawPosition( int x, int y ) // setzt die Zeichenposition
-{
-    lock();
-    drawPos.x = x;
-    drawPos.y = y;
-    unlock();
-}
-
-void Schrift::setDrawPosition( Punkt &pos )
-{
-    lock();
-    drawPos = pos;
-    unlock();
-}
-
-void Schrift::setSchriftSize( int sg ) // setzt die Schriftgröße
-{
-    lock();
     schriftSize = sg;
-    alphabet->setDrawSchriftSize( sg );
-    unlock();
 }
 
-void Schrift::setZeilenAbstand( int za ) // setzt den Zeilenabstand
+// Setzt den Zeilenabstand, der zum zeichnen verwendet werden soll
+//  za: Der Zeilenabstand zum unteren Ende der darüber liegenden zeile in Pixeln
+void TextRenderer::setZeilenAbstand( int za )
 {
-    lock();
     zeilenAbstand = za;
-    alphabet->setZeilenAbstand( za );
-    unlock();
 }
 
-void Schrift::textFormatieren( Text *zText, int maxBreite, int schriftSize ) // fügt zeilenumbrüche ein
+// Setzt den Zeichenabstand, der zum zeichnen verwendet werden soll
+//  za: Der Zeichenabstand zum unteren Ende der darüber liegenden zeile in Pixeln
+void TextRenderer::setZeichenAbstand( int za )
 {
-    lock();
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
-    {
-        for( int i = 0; i < 256; ++i )
-        {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
-        }
-    }
-    if( drawAlphabet )
-        drawAlphabet->textFormatieren( zText, maxBreite, schriftSize );
-    unlock();
+    zeichenAbstand = za;
 }
 
-void Schrift::renderText( Text *zTxt, Bild &zRObj, std::function< int( int, int, int ) > f ) // zeichnet txt nach zRObj
+// Fügt Zeilenumbrüche in den Text ein, so dass er bei einer vorgegebenen Breite follständig angezeigt wird
+//  zText: Der text, in den die Zeilenumbrüche eingefügt werden sollen
+//  maxBreite: Die Breite in Pixeln auf der der Text follständig angezeigt werden soll
+void TextRenderer::textFormatieren( Text *zTxt, int maxBreite )
 {
-    lock();
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
+    int lastPos = -1;
+    int x = 0;
+    const char *txt = zTxt->getText();
+    Text result = txt;
+    int len = zTxt->getLength();
+    for( int i = 0; txt[ i ]; ++i )
     {
-        for( int i = 0; i < 256; ++i )
+        if( txt[ i ] == ' ' )
         {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
+            lastPos = i;
+            x += schriftSize / 2 + zeichenAbstand;
+            continue;
         }
-    }
-    if( drawAlphabet )
-    {
-        drawAlphabet->setDrawPosition( drawPos.x, drawPos.y );
-        drawAlphabet->render( zTxt, zRObj, f );
-    }
-    unlock();
-}
-
-void Schrift::renderText( Text *zTxt, Bild &zRObj, int f ) // zeichnet txt nach zRObj
-{
-    lock();
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
-    {
-        for( int i = 0; i < 256; ++i )
+        if( txt[ i ] == '\t' )
         {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
+            lastPos = i;
+            x += schriftSize + zeichenAbstand;
+            continue;
         }
-    }
-    if( drawAlphabet )
-    {
-        drawAlphabet->setDrawPosition( drawPos.x, drawPos.y );
-        drawAlphabet->render( zTxt, zRObj, f );
-    }
-    unlock();
-}
-
-void Schrift::renderText( Text *zTxt, Bild &zRObj, int cpos, int cf, int fbeg, int ff, std::function< int( int, int, int ) > f )
-{
-    lock();
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
-    {
-        for( int i = 0; i < 256; ++i )
+        if( txt[ i ] == '\n' )
         {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
+            x = 0;
+            lastPos = -1;
+            continue;
+        }
+        if( txt[ i ] == '\r' && len - i >= 11 )
+        {
+            i += 10;
+            continue;
+        }
+        x += getCharWidth( txt[ i ] ) + zeichenAbstand;
+        if( x > maxBreite && lastPos > -1 )
+        {
+            result.ersetzen( lastPos, lastPos + 1, "\n" );
+            x = 0;
+            i = lastPos;
+            lastPos = -1;
         }
     }
-    if( drawAlphabet )
-    {
-        drawAlphabet->setDrawPosition( drawPos.x, drawPos.y );
-        drawAlphabet->render( zTxt, zRObj, cpos, cf, fbeg, ff, f );
-    }
-    unlock();
-}
-
-void Schrift::renderText( Text *zTxt, Bild &zRObj, int cpos, int cf, int fbeg, int ff, int f )
-{
-    lock();
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
+    zTxt->setText( result );
+}
+
+// Zeichnet einen Bestimmten Text mit Cursor und einfärbung auf ein Bild
+// Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
+//  x: x position des ersten zeichens
+//  y: y position des ersten zeichens
+//  txt: Der Text, der gezeichnet werden soll
+//  zRObj: Das Bild, auf das gezeichnet werden soll
+//  cpos: Die position des Cursors im Text
+//  cf: Die Farbe des Cursors
+//  fbeg: Die Position des Zeichens im Text, wo die Einfärbung beginnen soll. Der Text wird von dort bis zur Cursorposition eingefärbt
+//  ff: Die Hintergrund Farbe des eingefärbten Textes
+//  f: Eine Funktion die für jeden Buchstaben aufgerufen wird und seine Farbe zurückgibt
+void TextRenderer::renderText( int x, int y, const char *txt, Bild &zRObj, std::function< int( int, int, int ) > f, int cpos, int cf, int fbeg, int ff )
+{
+    if( !s )
+        return;
+    int zRObjBr = zRObj.getBreite();
+    int zRObjHi = zRObj.getHeight();
+    int beginX = x;
+    int zh = getZeilenHeight();
+    if( y + ( zh + zeilenAbstand ) * Text( txt ).anzahlVon( '\n' ) + zh < 0 || x >= zRObjBr || y >= zRObjHi )
+        return;
+    bool faerb = 0;
+    for( int i = 0; txt[ i ]; ++i )
     {
-        for( int i = 0; i < 256; ++i )
+        if( i == fbeg )
+            faerb = !faerb;
+        if( i == cpos )
         {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
+            zRObj.drawLinieVAlpha( x, y, zh, cf );
+            faerb = !faerb;
         }
+        if( txt[ i ] == ' ' )
+        {
+            if( faerb )
+                zRObj.alphaRegion( x, y, schriftSize / 2 + zeichenAbstand, zh, ff );
+            x += schriftSize / 2 + zeichenAbstand;
+            continue;
+        }
+        if( txt[ i ] == '\t' )
+        {
+            if( faerb )
+                zRObj.alphaRegion( x, y, schriftSize + zeichenAbstand, zh, ff );
+            x += schriftSize + zeichenAbstand;
+            continue;
+        }
+        if( txt[ i ] == '\n' )
+        {
+            y += zh + zeilenAbstand;
+            x = beginX;
+            continue;
+        }
+        if( txt[ i ] == '\r' && textLength( txt ) - i >= 11 )
+        {
+            i += 3;
+            Text *hex1 = Text( txt ).getTeilText( i, i + 6 );
+            Text *hex2 = Text( txt ).getTeilText( i + 6, i + 8 );
+            int nf = ( TextZuInt( hex1->getText(), 16 ) << 8 ) |
+                ( TextZuInt( hex2->getText(), 16 ) );
+            f = [ nf ]( int a, int b, int c )
+            {
+                return nf;
+            };
+            hex1->release();
+            hex2->release();
+            i += 7;
+            continue;
+        }
+        renderChar( x, y, txt[ i ], zRObj, faerb, ff, f( x, y, i ) );
     }
-    if( drawAlphabet )
+    if( textLength( txt ) == cpos )
+        zRObj.drawLinieVAlpha( x, y, zh, cf );
+}
+
+// Zeichnet einen Bestimmten Text mit Cursor und einfärbung auf ein Bild
+// Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
+//  x: x position des ersten zeichens
+//  y: y position des ersten zeichens
+//  txt: Der Text, der gezeichnet werden soll
+//  zRObj: Das Bild, auf das gezeichnet werden soll
+//  cpos: Die position des Cursors im Text
+//  cf: Die Farbe des Cursors
+//  fbeg: Die Position des Zeichens im Text, wo die Einfärbung beginnen soll. Der Text wird von dort bis zur Cursorposition eingefärbt
+//  ff: Die Hintergrund Farbe des eingefärbten Textes
+//  f: Die Farbe, in der der Text gezeichnet werden soll
+void TextRenderer::renderText( int x, int y, const char *txt, Bild &zRObj, int f, int cpos, int cf, int fbeg, int ff )
+{
+    return renderText( x, y, txt, zRObj, [ f ]( int a, int b, int c ) { return f; }, cpos, cf, fbeg, ff );
+}
+
+// Zeichnet einen Bestimmten Buchstaben mit einfärbung auf ein Bild
+// Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
+//  x: x position des ersten zeichens
+//  y: y position des ersten zeichens
+//  txt: Der Text, der gezeichnet werden soll
+//  zRObj: Das Bild, auf das gezeichnet werden soll
+//  selected: 1, falls das zeichen eingefärbt sein soll
+//  ff: Die Hintergrund Farbe des eingefärbten Textes
+//  f: Die Farbe, in der der Text gezeichnet werden soll
+void TextRenderer::renderChar( int &x, int y, char c, Bild &zRObj, bool selected, int ff, int f )
+{
+    if( !s )
+        return;
+    Alphabet *a = s->zAlphabet( schriftSize );
+    Buchstabe *b = a->zBuchstabe( c );
+    if( b )
     {
-        drawAlphabet->setDrawPosition( drawPos.x, drawPos.y );
-        drawAlphabet->render( zTxt, zRObj, cpos, cf, fbeg, ff, f );
+        if( x >= zRObj.getBreite() )
+            return;
+        if( zRObj.isAreaDrawable( x, y, getCharWidth( c ), getCharHeight( c ) ) )
+        {
+            if( selected )
+            {
+                int br = getCharWidth( c ) + zeichenAbstand;
+                zRObj.alphaRegion( x, y, br, getZeilenHeight(), ff );
+            }
+            if( b->getBuff() )
+            {
+                const Punkt &zRObjGr = zRObj.getDrawGr();
+                const Punkt &zRObjPos = zRObj.getDrawPos();
+                const Punkt &zRObjOff = zRObj.getDrawOff();
+                int xp = x + zRObjOff.x, yp = y + zRObjOff.y;
+                int xs = xp < zRObjPos.x ? ( zRObjPos.x - xp ) : 0, ys = yp < zRObjPos.y ? ( zRObjPos.y - yp ) : 0;
+                int br = b->getBreite(), h = b->getHeight();
+                unsigned char a2 = (unsigned char)( 255 - ( f >> 24 ) );
+                f &= 0x00FFFFFF;
+                if( schriftSize == b->getSchriftSize() )
+                {
+                    if( xp >= zRObjGr.x || yp >= zRObjGr.y || xp + br < zRObjPos.x || yp + h < zRObjPos.y )
+                        return;
+                    br = ( xp + br ) > zRObjGr.x ? ( zRObjGr.x - xp ) : br;
+                    h = ( yp + h ) > zRObjGr.y ? ( zRObjGr.y - yp ) : h;
+                    if( !a2 )
+                    {
+                        int xx, ygr = ( ys - 1 ) * b->getBreite(), ygr2 = ( yp + ys - 1 ) * zRObj.getBreite();
+                        for( int yy = ys; yy < h; ++yy )
+                        {
+                            ygr += b->getBreite();
+                            ygr2 += zRObj.getBreite();
+                            for( xx = xs; xx < br; ++xx )
+                                zRObj.alphaPixel( xp + xx + ygr2, f | ( b->getBuff()[ xx + ygr ] << 24 ) );
+                        }
+                    }
+                    else
+                    {
+                        int a;
+                        int xx, ygr = ( ys - 1 ) * b->getBreite(), ygr2 = ( yp + ys - 1 ) * zRObj.getBreite();
+                        for( int yy = ys; yy < h; ++yy )
+                        {
+                            ygr += b->getBreite();
+                            ygr2 += zRObj.getBreite();
+                            for( xx = xs; xx < br; ++xx )
+                            {
+                                a = b->getBuff()[ xx + ygr ] - a2;
+                                if( a > 0 )
+                                    zRObj.alphaPixel( xp + xx + ygr2, f | ( a << 24 ) );
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    double xoff = (double)b->getSchriftSize() / (double)schriftSize,
+                        yoff = (double)b->getSchriftSize() / (double)schriftSize;
+                    double x = xs * xoff, y = ys * yoff;
+                    int maxX = getCharWidth( c ), maxY = getCharHeight( c );
+                    maxX = ( xp + maxX ) >= zRObjGr.x ? ( zRObjGr.x - xp ) : maxX;
+                    maxY = ( yp + maxY ) >= zRObjGr.y ? ( zRObjGr.y - yp ) : maxY;
+                    if( !a2 )
+                    {
+                        int dx, ygr, ygr2;
+                        for( int dy = ys; dy < maxY; ++dy )
+                        {
+                            ygr2 = ( yp + dy ) * zRObj.getBreite();
+                            ygr = (int)y * br;
+                            for( dx = xs; dx < maxX; ++dx )
+                            {
+                                zRObj.alphaPixel( xp + dx + ygr2, f | ( b->getBuff()[ (int)x + ygr ] << 24 ) );
+                                x += xoff;
+                            }
+                            x = xs;
+                            y += yoff;
+                        }
+                    }
+                    else
+                    {
+                        int a, dx, ygr, ygr2;
+                        for( int dy = ys; dy < maxY; ++dy )
+                        {
+                            ygr2 = ( yp + dy ) * zRObj.getBreite();
+                            ygr = (int)y * br;
+                            for( dx = xs; dx < maxX; ++dx )
+                            {
+                                a = b->getBuff()[ (int)x + ygr ] - a2;
+                                zRObj.alphaPixel( xp + dx + ygr2, f | ( a << 24 ) );
+                                x += xoff;
+                            }
+                            x = xs;
+                            y += yoff;
+                        }
+                    }
+                }
+            }
+        }
+        x += getCharWidth( c ) + zeichenAbstand;
     }
-    unlock();
 }
 
-// constant 
-Alphabet *Schrift::getAlphabet( int sg ) const // gibt einen Alphaberarray zurück
+// Gibt die Schriftgröße zurück, die zum Zeichnen verwendet wird
+int TextRenderer::getSchriftSize() const
 {
-    return alphabet->getAlphabet( (unsigned char)sg );
+    return schriftSize;
 }
 
-Alphabet *Schrift::zAlphabet( int sg ) const
+// Gibt den Abstand in Pixeln zum unteren Ende der darüber ligenden Zeile zurück
+int TextRenderer::getZeilenabstand() const
 {
-    return alphabet->zAlphabet( (unsigned char)sg );
+    return zeilenAbstand;
 }
 
-Alphabet *Schrift::getAlphabetI( int index ) const
+// Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
+//  txt: Der Text, von dem die Breite in Pixeln ermitelt werden soll
+int TextRenderer::getTextBreite( const char *txt ) const
 {
-    return alphabet->getAlphabetI( index, 0 );
+    int ret = 0;
+    int tmp = 0;
+    for( int i = 0; txt[ i ]; ++i )
+    {
+        if( txt[ i ] == '\n' )
+        {
+            if( tmp > ret )
+                ret = tmp;
+            tmp = 0;
+        }
+        else if( txt[ i ] == '\r' )
+        {
+            i += 10;
+            continue;
+        }
+        else if( txt[ i ] == '\t' )
+            tmp += schriftSize + zeichenAbstand;
+        else if( txt[ i ] == ' ' )
+            tmp += schriftSize / 2 + zeichenAbstand;
+        else
+            tmp += getCharWidth( txt[ i ] ) + zeichenAbstand;
+    }
+    if( tmp > ret )
+        ret = tmp;
+    return ret;
 }
 
-Alphabet *Schrift::zAlphabetI( int index ) const
+// Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
+//  txt: Der Text, von dem die Höhe in Pixeln ermitelt werden soll
+int TextRenderer::getTextHeight( const char *txt ) const
 {
-    return alphabet->zAlphabetI( index, 0 );
+    int hi = getZeilenHeight();
+    return hi + ( ( hi + zeilenAbstand ) * Text( txt ).anzahlVon( '\n' ) );
 }
 
-unsigned char Schrift::getAlphabetAnzahl() const // gibt die anzahl von in der Schrift enthaltenen Alphabeten zurück
+// Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Buchstaben vollständig darzustellen
+//  c: Der Buchstabe, von dem die Breite in Pixeln ermitelt werden soll
+int TextRenderer::getCharWidth( const char c ) const
 {
-    return alphabetAnzahl;
+    if( !s )
+        return 0;
+    Alphabet *a = s->zAlphabet( schriftSize );
+    Buchstabe *b = a->zBuchstabe( c );
+    if( b )
+        return (int)( ( (double)b->getBreite() / (double)b->getSchriftSize() ) * (double)schriftSize + 0.5 );
+    return 0;
 }
 
-int Schrift::getSchriftSize() const // gibt die Schriftgröße zurück
+// Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
+//  c: Der Buchstabe, von dem die Höhe in Pixeln ermitelt werden soll
+int TextRenderer::getCharHeight( const char c ) const
 {
-    return schriftSize;
+    if( !s )
+        return 0;
+    Alphabet *a = s->zAlphabet( schriftSize );
+    Buchstabe *b = a->zBuchstabe( c );
+    if( b )
+        return (int)( ( (double)b->getHeight() / (double)b->getSchriftSize() ) * (double)schriftSize + 0.5 );
+    return 0;
 }
 
-int Schrift::getZeilenabstand() const // gibt den Zeilenabstand zurück
+// Gibt den Abstand in Pixeln zum unteren Ende der darüber ligenden Zeile zurück
+int TextRenderer::getZeilenAbstand() const
 {
     return zeilenAbstand;
 }
 
-int Schrift::getDrawX() const // gibt die Zeichenposition zurück
-{
-    return drawPos.x;
-}
-
-int Schrift::getDrawY() const
+// Gibt die skallierte Höhe zurück, die eine gezeichnete Zeile in Pixeln benötigt
+int TextRenderer::getZeilenHeight() const
 {
-    return drawPos.y;
-}
-
-const Punkt &Schrift::getDrawPosition() const
-{
-    return drawPos;
-}
-
-int Schrift::getTextBreite( Text *zTxt ) const // gibt die Breite des Textes zurück
-{
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
+    int zh = 0;
+    for( int i = 0; i < 256; ++i )
     {
-        for( int i = 0; i < 256; ++i )
-        {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
-        }
+        zh = maxInt( getCharHeight( (char)i ), zh );
     }
-    if( !drawAlphabet )
-        return 0;
-    return drawAlphabet->getTextBreite( zTxt );
+    return zh;
 }
 
-int Schrift::getTextHeight( Text *zTxt ) const // gibt die Höhe des Textes zurück
+// Ermittelt das Zeichen im Text, auf das die Maus zeigt
+//  txt: Der Text, auf den die Maus Zeigt
+//  mausX: Die X Position der Maus in Pixeln Relativ zur Position des ersten Zeichens
+//  mausY: Die Y Position der Maus in Pixeln Relativ zur Position des ersten Zeichens
+int TextRenderer::textPos( const char *txt, int mausX, int mausY ) const
 {
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
-    {
-        for( int i = 0; i < 256; ++i )
-        {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
-        }
-    }
-    if( !drawAlphabet )
-        return 0;
-    return drawAlphabet->getTextHeight( zTxt );
-}
-
-int Schrift::textPos( Text *zTxt, int mausX, int mausY ) const // gibt den Buchstaben zurück, auf den die Maus zeigt
-{
-    Alphabet *drawAlphabet = alphabet->zAlphabet( (unsigned char)schriftSize );
-    if( !drawAlphabet )
+    int tx = 0;
+    int ty = 0;
+    int sh = getZeilenHeight();
+    if( mausX < 0 || mausY < 0 )
+        return -1;
+    for( int i = 0; i < txt[ i ]; ++i )
     {
-        for( int i = 0; i < 256; ++i )
+        if( txt[ i ] == '\n' )
         {
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize - i ) );
-            if( drawAlphabet )
-                break;
-            drawAlphabet = alphabet->zAlphabet( (unsigned char)( schriftSize + i ) );
-            if( drawAlphabet )
-                break;
+            ty += sh + zeilenAbstand;
+            tx = 0;
+            if( mausY < ty )
+                return i;
         }
+        if( txt[ i ] == '\t' )
+            tx += schriftSize + zeichenAbstand;
+        if( txt[ i ] == ' ' )
+            tx += schriftSize / 2 + zeichenAbstand;
+        tx += getCharWidth( txt[ i ] );
+        int txpl = getCharWidth( txt[ i + 1 ] ) / 2;
+        if( mausX < tx - txpl && mausY < ty + sh + zeilenAbstand )
+            return i;
     }
-    if( !drawAlphabet )
-        return 0;
-    return drawAlphabet->textPos( zTxt, mausX, mausY );
+    if( mausY < ty + sh + zeilenAbstand )
+        return textLength( txt );
+    return -1;
 }
 
-// Reference Counting 
-Schrift *Schrift::getThis()
+TextRenderer *TextRenderer::getThis()
 {
-    ++ref;
+    ref++;
     return this;
 }
 
-Schrift *Schrift::release()
+TextRenderer *TextRenderer::release()
 {
-    --ref;
-    if( ref == 0 )
+    if( !--ref )
         delete this;
     return 0;
 }

+ 87 - 177
Schrift.h

@@ -21,10 +21,8 @@ namespace Framework
     {
     private:
         Punkt size;
-        Punkt pos;
         unsigned char *alpha;
         int schriftSize;
-        int drawSg;
         int ref;
 
     public:
@@ -32,7 +30,6 @@ namespace Framework
         __declspec( dllexport ) Buchstabe();
         // Löscht das Zeichnung
         __declspec( dllexport ) ~Buchstabe();
-
         // Erstellt einen neuen Buchstaben mit bestimmter Größe
         //  size: Die Größe des Buchstabens in Pixel
         __declspec( dllexport ) void NeuBuchstabe( Punkt &size );
@@ -49,36 +46,19 @@ namespace Framework
         //  i: der Index des Pixels. Er berechnet sich durch x + y * breite und geht von 0 bis breite * höhe - 1
         //  alpha: Der Wert des Pixels
         __declspec( dllexport ) void setPixel( int i, unsigned char alpha );
-        // Setzt die Position, an die der Buchstabe gezeichnet werden soll
-        //  pos: Die position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        __declspec( dllexport ) void setPosition( Punkt &pos );
-        // Setzt die Position, an die der Buchstabe gezeichnet werden soll
-        //  x: Die x position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        //  y: Die y position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        __declspec( dllexport ) void setPosition( int x, int y );
         // Setzt die Schriftgröße, zu der der Buchstabe gehört
-        //  sg: Die Schriftgröße des Buchstabens. Wenn der Buchstabe in einer anderen größe gezeichnet werden soll, wird automatisch skalliert
+        //  sg: Die Schriftgröße des Buchstabens.
         __declspec( dllexport ) void setSchriftSize( int sg );
-        // Setzt die Schriftgröße, in der der Buchstabe gezeichnet werden soll
-        //  dsg: Die Schriftgröße, in der der Buchstabe gezeichnet werden soll. Ist die ungleich der Schriftgröße, zu der der Buchstabe gehört, so wird automatisch skalliert.
-        __declspec( dllexport ) void setDrawSchriftSize( int dsg );
-
+        // Gibt die Schriftgröße zurück, zu der der Buchstabe gehört
+        __declspec( dllexport ) int getSchriftSize() const;
         // Gibt die alpha Werte des Buchstabens als array zurück wobei die werte Zeilenweise hintereinander stehen
         __declspec( dllexport ) unsigned char *getBuff() const;
         // Gibt die Größe des Buchstabens in Pixeln nicht skalliert zurück.
         __declspec( dllexport ) const Punkt &getSize() const;
-        // Gibt die Breite des Buchstabens in Pixeln zurück (Der Wert wurde bereits mit der Draw Schriftgröße skalliert)
+        // Gibt die Breite des Buchstabens in Pixeln zurück
         __declspec( dllexport ) int getBreite() const;
-        // Gibt die Höhe des Buchstabens in Pixeln zurück (Der Wert wurde bereits mit der Draw Schriftgröße skalliert)
+        // Gibt die Höhe des Buchstabens in Pixeln zurück
         __declspec( dllexport ) int getHeight() const;
-        // Gibt die nicht skallierte Höhe des Buchstabens in Pixeln zurück
-        __declspec( dllexport ) int getNormHeight() const;
-        // Zeichnet den Buchstaben in ein bestimmtes Bild
-        // Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
-        //  zRObj: Das Bild, in den der Buchstabe gezeichnet werden soll
-        //  f: Die Farbe, in der der Buchstabe gezeichnet werden soll
-        __declspec( dllexport ) void render( Bild &zRObj, int f ) const;
-
         // Erhöht den Reference Counting Zähler.
         //  return: this.
         __declspec( dllexport ) Buchstabe *getThis();
@@ -94,10 +74,6 @@ namespace Framework
     private:
         Buchstabe **zeichen;
         int schriftSize;
-        int drawSchriftSize;
-        Punkt pos;
-        int zeilenHeight;
-        int zeilenAbstand;
         int ref;
 
     public:
@@ -105,7 +81,6 @@ namespace Framework
         __declspec( dllexport ) Alphabet();
         // Löscht ein Zeichnung
         __declspec( dllexport ) ~Alphabet();
-
         // Löscht alle gespeicherten Zeichen
         __declspec( dllexport ) void NeuAlphabet();
         // Fügt dem Alphabet einen Buchstaben hinzu
@@ -116,20 +91,6 @@ namespace Framework
         // Setzt die Schriftgröße des Alphabets und die der gespeicherten buchstaben
         //  gr: Die Schriftgröße des Alphabets
         __declspec( dllexport ) void setSchriftSize( int gr );
-        // Setzt die Schriftgröße, in der die gespeicherten Buchstaben gezeichnet werden sollen.
-        //  gr: Die Zeichen Schriftgröße. Wenn sie ungleich der Schriftgröße des Alphabets ist, wird automatisch skalliert
-        __declspec( dllexport ) void setDrawSchriftSize( int gr );
-        // Setzt den Zeilenabstand beim Zeichnen eines Textes
-        //  za: Der Abschtand zum unteren Ende der Zeile darüber in Pixeln
-        __declspec( dllexport ) void setZeilenAbstand( int za );
-        // Setzt die Position, an die der Erste buchstabe gezeichnet werden soll
-        //  pos: Die position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        __declspec( dllexport ) void setDrawPosition( Punkt &pos );
-        // Setzt die Position, an die der Erste buchstabe gezeichnet werden soll
-        //  x: Die x Position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        //  y: Die y Position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        __declspec( dllexport ) void setDrawPosition( int x, int y );
-
         // Gibt den gespeicherten Buchstaben zu einem bestimmten ASCII Zeichen zurück
         //  i: Der ASCII code des Zeichens
         //  return: Ein Zeiger zu dem Buchstaben mit erhöhtem Reference Counter
@@ -144,63 +105,6 @@ namespace Framework
         __declspec( dllexport ) bool hatBuchstabe( unsigned char b ) const;
         // Gibt die Schriftgröße zurück, deren Zeichen in diesem Alphabet gespeichert werden
         __declspec( dllexport ) int getSchriftSize() const;
-        // Gibt die Schriftgröße zurück, in der die gespeicherten Zeichen gezeichnet werden
-        __declspec( dllexport ) int getDrawSchriftSize() const;
-        // Gibt den Abstand in Pixeln zum unteren Ende der darüber ligenden Zeile zurück
-        __declspec( dllexport ) int getZeilenAbstand() const;
-        // Gibt die skallierte Höhe zurück, die eine gezeichnete Zeile in Pixeln benötigt
-        __declspec( dllexport ) int getZeilenHeight() const;
-        // gibt die Position zurück, an der der erste Buchstabe gezeichnet wird
-        __declspec( dllexport ) const Punkt &getPosition() const;
-        // Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
-        //  zTxt: Der Text, von dem die Breite in Pixeln ermitelt werden soll
-        __declspec( dllexport ) int getTextBreite( Text *zTxt ) const;
-        // Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
-        //  zTxt: Der Text, von dem die Höhe in Pixeln ermitelt werden soll
-        __declspec( dllexport ) int getTextHeight( Text *zTxt ) const;
-        // Ermittelt das Zeichen im Text, auf das die Maus zeigt
-        //  zTxt: Der Text, auf den die Maus Zeigt
-        //  mausX: Die X Position der Maus in Pixeln Relativ zur Position des ersten Zeichens
-        //  mausY: Die Y Position der Maus in Pixeln Relativ zur Position des ersten Zeichens
-        __declspec( dllexport ) int textPos( Text *zTxt, int mausX, int mausY ) const;
-        // Fügt Zeilenumbrüche in den Text ein, so dass er bei einer vorgegebenen Breite follständig angezeigt wird
-        //  zText: Der text, in den die Zeilenumbrüche eingefügt werden sollen
-        //  maxBreite: Die Breite in Pixeln auf der der Text follständig angezeigt werden soll
-		//  schriftSize: Die Schriftgröße, in der der Text passend dargestellt werden soll
-        __declspec( dllexport ) void textFormatieren( Text *zText, int maxBreite, int schriftSize );
-        // Zeichnet einen Bestimmten Text auf ein Bild
-        // Nutze (setDrawPosition) und (setSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
-        //  zRObj: Das Bild, auf das gezeichnet werden soll
-        //  f: Eine Funktion die für jeden Buchstaben aufgerufen wird und seine Farbe zurückgibt
-        __declspec( dllexport ) void render( Text *zTxt, Bild &zRObj, std::function< int( int, int, int ) > f ) const;
-        // Zeichnet einen Bestimmten Text auf ein Bild
-        // Nutze (setDrawPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
-        //  zRObj: Das Bild, auf das gezeichnet werden soll
-        //  f: Die Farbe, in der der Text gezeichnet werden soll
-        __declspec( dllexport ) void render( Text *zTxt, Bild &zRObj, int f ) const;
-        // Zeichnet einen Bestimmten Text mit Cursor und einfärbung auf ein Bild
-        // Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
-        //  zRObj: Das Bild, auf das gezeichnet werden soll
-        //  cpos: Die position des Cursors im Text
-        //  cf: Die Farbe des Cursors
-        //  fbeg: Die Position des Zeichens im Text, wo die Einfärbung beginnen soll. Der Text wird von dort bis zur Cursorposition eingefärbt
-        //  ff: Die Hintergrund Farbe des eingefärbten Textes
-        //  f: Eine Funktion die für jeden Buchstaben aufgerufen wird und seine Farbe zurückgibt
-        __declspec( dllexport ) void render( Text *zTxt, Bild &zRObj, int cpos, int cf, int fbeg, int ff, std::function< int( int, int, int ) > f ) const;
-        // Zeichnet einen Bestimmten Text mit Cursor und einfärbung auf ein Bild
-        // Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
-        //  zRObj: Das Bild, auf das gezeichnet werden soll
-        //  cpos: Die position des Cursors im Text
-        //  cf: Die Farbe des Cursors
-        //  fbeg: Die Position des Zeichens im Text, wo die Einfärbung beginnen soll. Der Text wird von dort bis zur Cursorposition eingefärbt
-        //  ff: Die Hintergrund Farbe des eingefärbten Textes
-        //  f: Die Farbe, in der der Text gezeichnet werden soll
-        __declspec( dllexport ) void render( Text *zTxt, Bild &zRObj, int cpos, int cf, int fbeg, int ff, int f ) const;
-
         // Erhöht den Reference Counting Zähler.
         //  return: this.
         __declspec( dllexport ) Alphabet *getThis();
@@ -232,12 +136,6 @@ namespace Framework
         //  sg: Die Schriftgröße des Alphabets, welches entfernt werden soll
         //  return: (true), wenn ein Alphabet entfernt wurde. (false) sonnst
         __declspec( dllexport ) bool removeAlphabet( int sg );
-        // Setzt die Schriftgröße, in der gezeichnet werden soll
-        //  sg: Die Schriftgröße
-        __declspec( dllexport ) void setDrawSchriftSize( int sg );
-        // Setzt den Zeilenabstand, der zum zeichnen verwendet werden soll
-        //  za: Der Zeilenabstand zum unteren Ende der darüber liegenden zeile in Pixeln
-        __declspec( dllexport ) void setZeilenAbstand( int za );
         // Setzt den Zeiger auf das nächste Element der Liste auf 0
         __declspec( dllexport ) void setNext0();
 
@@ -269,10 +167,6 @@ namespace Framework
     private:
         unsigned char alphabetAnzahl;
         AlphabetArray *alphabet;
-        int schriftSize;
-        int zeilenAbstand;
-        Punkt drawPos;
-        Critical cs;
         int ref;
 
     public:
@@ -280,14 +174,6 @@ namespace Framework
         __declspec( dllexport ) Schrift();
         // Löscht ein Zeichnung
         __declspec( dllexport ) ~Schrift();
-
-        // Bereitet die Schrift auf das zeichnen eines Textes vor.
-        // Dies ist notwendig, falls mehrere Threads gleichzeitig die Schrift benutzen
-        __declspec( dllexport ) void lock();
-        // Beendet den Zeichenforgang der Schrift
-        // Muss für jeden aufruf von (lock();) einmal vom selben Thread aufgerufen werden,
-        // damit die Schrift wieder von anderen Threads verwendet werden kann
-        __declspec( dllexport ) void unlock();
         // Fügt der Schrift ein Alphabet hinzu. Sollte bereits ein Alphabet der selben Schriftgröße existieren, wird das Alphabet nicht hinzugefügt
         //  alphabet: Das Alphabet, welches hinzugefügt werden soll
         //  return: (true), wenn das Alphabet hinzugefügt wurde. (false) sonnst
@@ -295,102 +181,126 @@ namespace Framework
         // Löscht ein bestimmtes Alphabet aus der Schrift
         //  sg: Die Schriftgröße, deren Alphabet entfernt werden soll
         __declspec( dllexport ) void removeAlphabet( int sg );
-        // Setzt die Position, an die der Erste buchstabe gezeichnet werden soll
-        //  x: Die x Position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        //  y: Die y Position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        __declspec( dllexport ) void setDrawPosition( int x, int y );
-        // Setzt die Position, an die der Erste buchstabe gezeichnet werden soll
-        //  pos: Die Position relativ zu der Draw Position im zeichen Bild (siehe Bild::setDrawOptions)
-        __declspec( dllexport ) void setDrawPosition( Punkt &pos );
+        // Gibt ein bestimmtes Alphabet mit erhöhtem Reference Counter zurück
+        //  sg: Die Schriftgröße, dessen Alphabet gesucht werden soll
+        //  return: (0), fals kein passendes Alphabet gefunden wurde
+        __declspec( dllexport ) Alphabet *getAlphabet( int sg ) const;
+        // Gibt ein bestimmtes Alphabet ohne erhöhtem Reference Counter zurück
+        //  sg: Die Schriftgröße, dessen Alphabet gesucht werden soll
+        //  return: (0), fals kein passendes Alphabet gefunden wurde
+        __declspec( dllexport ) Alphabet *zAlphabet( int sg ) const;
+        // Gibt ein bestimmtes Alphabet mit erhöhtem Reference Counter zurück
+        //  index: Der Index des gesuchten Alphabets in der Reihenfolge wie sie der Liste hinzugefügt wurden
+        //  return: (0), fals kein passendes Alphabet gefunden wurde
+        __declspec( dllexport ) Alphabet *getAlphabetI( int index ) const;
+        // Gibt ein bestimmtes Alphabet ohne erhöhtem Reference Counter zurück
+        //  index: Der Index des gesuchten Alphabets in der Reihenfolge wie sie der Liste hinzugefügt wurden
+        //  return: (0), fals kein passendes Alphabet gefunden wurde
+        __declspec( dllexport ) Alphabet *zAlphabetI( int index ) const;
+        // Gibt zurück, wie viele Alphabete (und damit Schriftgrößen) in der Schrift enthalten sind
+        __declspec( dllexport ) unsigned char getAlphabetAnzahl() const;
+        // Erhöht den Reference Counting Zähler.
+        //  return: this.
+        __declspec( dllexport ) Schrift *getThis();
+        // Verringert den Reference Counting Zähler. Wenn der Zähler 0 erreicht, wird das Zeichnung automatisch gelöscht.
+        //  return: 0.
+        __declspec( dllexport ) Schrift *release();
+    };
+
+    class TextRenderer
+    {
+    protected:
+        Schrift *s;
+        int schriftSize;
+        int zeilenAbstand;
+        int zeichenAbstand;
+        int ref;
+
+    public:
+        __declspec( dllexport ) TextRenderer();
+        __declspec( dllexport ) TextRenderer( Schrift *schrift );
+        __declspec( dllexport ) virtual ~TextRenderer();
+        __declspec( dllexport ) void setSchriftZ( Schrift *schrift );
+        __declspec( dllexport ) Schrift *getSchrift();
+        __declspec( dllexport ) Schrift *zSchrift();
         // Setzt die Schriftgröße, in der gezeichnet werden soll. Die Schrift wählt automatisch das passende Alphabet zum Zeichnen
         //  sg: Die Schriftgröße
         __declspec( dllexport ) void setSchriftSize( int sg );
         // Setzt den Zeilenabstand, der zum zeichnen verwendet werden soll
         //  za: Der Zeilenabstand zum unteren Ende der darüber liegenden zeile in Pixeln
         __declspec( dllexport ) void setZeilenAbstand( int za );
+        // Setzt den Zeichenabstand, der zum zeichnen verwendet werden soll
+        //  za: Der Zeichenabstand zum unteren Ende der darüber liegenden zeile in Pixeln
+        __declspec( dllexport ) void setZeichenAbstand( int za );
         // Fügt Zeilenumbrüche in den Text ein, so dass er bei einer vorgegebenen Breite follständig angezeigt wird
         //  zText: Der text, in den die Zeilenumbrüche eingefügt werden sollen
         //  maxBreite: Die Breite in Pixeln auf der der Text follständig angezeigt werden soll
-        //  schriftSize: Die Schriftgröße, die verwendet werden soll
-        __declspec( dllexport ) void textFormatieren( Text *zText, int maxBreite, int schriftSize );
-        // Zeichnet einen Bestimmten Text auf ein Bild
-        // Nutze (setDrawPosition) und (setSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
-        //  zRObj: Das Bild, auf das gezeichnet werden soll
-        //  f: Eine Funktion die für jeden Buchstaben aufgerufen wird und seine Farbe zurückgibt
-        __declspec( dllexport ) void renderText( Text *zTxt, Bild &zRObj, std::function< int( int, int, int ) > f );
-        // Zeichnet einen Bestimmten Text auf ein Bild
-        // Nutze (setDrawPosition) und (setSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
-        //  zRObj: Das Bild, auf das gezeichnet werden soll
-        //  f: Die Farbe, in der der Text gezeichnet werden soll
-        __declspec( dllexport ) void renderText( Text *zTxt, Bild &zRObj, int f );
+        __declspec( dllexport ) virtual void textFormatieren( Text *zText, int maxBreite );
         // Zeichnet einen Bestimmten Text mit Cursor und einfärbung auf ein Bild
         // Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
+        //  x: x position des ersten zeichens
+        //  y: y position des ersten zeichens
+        //  txt: Der Text, der gezeichnet werden soll
         //  zRObj: Das Bild, auf das gezeichnet werden soll
         //  cpos: Die position des Cursors im Text
         //  cf: Die Farbe des Cursors
         //  fbeg: Die Position des Zeichens im Text, wo die Einfärbung beginnen soll. Der Text wird von dort bis zur Cursorposition eingefärbt
         //  ff: Die Hintergrund Farbe des eingefärbten Textes
         //  f: Eine Funktion die für jeden Buchstaben aufgerufen wird und seine Farbe zurückgibt
-        __declspec( dllexport ) void renderText( Text *zTxt, Bild &zRObj, int cpos, int cf, int fbeg, int ff, std::function< int( int, int, int ) > f );
+        __declspec( dllexport ) virtual void renderText( int x, int y, const char *txt, Bild &zRObj, std::function< int( int, int, int ) > f, int cpos = -1, int cf = 0, int fbeg = -1, int ff = 0 );
         // Zeichnet einen Bestimmten Text mit Cursor und einfärbung auf ein Bild
         // Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
-        //  zText: Der Text, der gezeichnet werden soll
+        //  x: x position des ersten zeichens
+        //  y: y position des ersten zeichens
+        //  txt: Der Text, der gezeichnet werden soll
         //  zRObj: Das Bild, auf das gezeichnet werden soll
         //  cpos: Die position des Cursors im Text
         //  cf: Die Farbe des Cursors
         //  fbeg: Die Position des Zeichens im Text, wo die Einfärbung beginnen soll. Der Text wird von dort bis zur Cursorposition eingefärbt
         //  ff: Die Hintergrund Farbe des eingefärbten Textes
         //  f: Die Farbe, in der der Text gezeichnet werden soll
-        __declspec( dllexport ) void renderText( Text *zTxt, Bild &zRObj, int cpos, int cf, int fbeg, int ff, int f );
-        // Gibt ein bestimmtes Alphabet mit erhöhtem Reference Counter zurück
-        //  sg: Die Schriftgröße, dessen Alphabet gesucht werden soll
-        //  return: (0), fals kein passendes Alphabet gefunden wurde
-        __declspec( dllexport ) Alphabet *getAlphabet( int sg ) const;
-        // Gibt ein bestimmtes Alphabet ohne erhöhtem Reference Counter zurück
-        //  sg: Die Schriftgröße, dessen Alphabet gesucht werden soll
-        //  return: (0), fals kein passendes Alphabet gefunden wurde
-        __declspec( dllexport ) Alphabet *zAlphabet( int sg ) const;
-        // Gibt ein bestimmtes Alphabet mit erhöhtem Reference Counter zurück
-        //  index: Der Index des gesuchten Alphabets in der Reihenfolge wie sie der Liste hinzugefügt wurden
-        //  return: (0), fals kein passendes Alphabet gefunden wurde
-        __declspec( dllexport ) Alphabet *getAlphabetI( int index ) const;
-        // Gibt ein bestimmtes Alphabet ohne erhöhtem Reference Counter zurück
-        //  index: Der Index des gesuchten Alphabets in der Reihenfolge wie sie der Liste hinzugefügt wurden
-        //  return: (0), fals kein passendes Alphabet gefunden wurde
-        __declspec( dllexport ) Alphabet *zAlphabetI( int index ) const;
-        // Gibt zurück, wie viele Alphabete (und damit Schriftgrößen) in der Schrift enthalten sind
-        __declspec( dllexport ) unsigned char getAlphabetAnzahl() const;
+        __declspec( dllexport ) virtual void renderText( int x, int y, const char *txt, Bild &zRObj, int f, int cpos = -1, int cf = 0, int fbeg = -1, int ff = 0 );
+        // Zeichnet einen Bestimmten Buchstaben mit einfärbung auf ein Bild
+        // Nutze (setPosition) und (setDrawSchriftGröße) um die Position und die Größe zu verändern
+        //  x: x position des ersten zeichens
+        //  y: y position des ersten zeichens
+        //  txt: Der Text, der gezeichnet werden soll
+        //  zRObj: Das Bild, auf das gezeichnet werden soll
+        //  selected: 1, falls das zeichen eingefärbt sein soll
+        //  ff: Die Hintergrund Farbe des eingefärbten Textes
+        //  f: Die Farbe, in der der Text gezeichnet werden soll
+        __declspec( dllexport ) virtual void renderChar( int &x, int y, char c, Bild &zRObj, bool selected, int ff, int f );
         // Gibt die Schriftgröße zurück, die zum Zeichnen verwendet wird
         __declspec( dllexport ) int getSchriftSize() const;
         // Gibt den Abstand in Pixeln zum unteren Ende der darüber ligenden Zeile zurück
         __declspec( dllexport ) int getZeilenabstand() const;
-        // Gibt die x Koordinate des ersten Zeichens, dass gezeichnet wird, in Pixeln zurück
-        __declspec( dllexport ) int getDrawX() const;
-        // Gibt die y Koordinate des ersten Zeichens, dass gezeichnet wird, in Pixeln zurück
-        __declspec( dllexport ) int getDrawY() const;
-        // Gibt die Position des ersten Zeichens, dass gezeichnet wird, in Pixeln zurück
-        __declspec( dllexport ) const Punkt &getDrawPosition() const;
         // Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
-        //  zTxt: Der Text, von dem die Breite in Pixeln ermitelt werden soll
-        __declspec( dllexport ) int getTextBreite( Text *zTxt ) const;
+        //  txt: Der Text, von dem die Breite in Pixeln ermitelt werden soll
+        __declspec( dllexport ) virtual int getTextBreite( const char *txt ) const;
+        // Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
+        //  txt: Der Text, von dem die Höhe in Pixeln ermitelt werden soll
+        __declspec( dllexport ) virtual int getTextHeight( const char *txt ) const;
+        // Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Buchstaben vollständig darzustellen
+        //  c: Der Buchstabe, von dem die Breite in Pixeln ermitelt werden soll
+        __declspec( dllexport ) virtual int getCharWidth( const char c ) const;
         // Ermittelt, wie viele Pixel benötigt werden, um einen Bestimmten Text vollständig darzustellen
-        //  zTxt: Der Text, von dem die Höhe in Pixeln ermitelt werden soll
-        __declspec( dllexport ) int getTextHeight( Text *zTxt ) const;
+        //  c: Der Buchstabe, von dem die Höhe in Pixeln ermitelt werden soll
+        __declspec( dllexport ) virtual int getCharHeight( const char c ) const;
+        // Gibt den Abstand in Pixeln zum unteren Ende der darüber ligenden Zeile zurück
+        __declspec( dllexport ) int getZeilenAbstand() const;
+        // Gibt die skallierte Höhe zurück, die eine gezeichnete Zeile in Pixeln benötigt
+        __declspec( dllexport ) int getZeilenHeight() const;
         // Ermittelt das Zeichen im Text, auf das die Maus zeigt
         //  zTxt: Der Text, auf den die Maus Zeigt
         //  mausX: Die X Position der Maus in Pixeln Relativ zur Position des ersten Zeichens
         //  mausY: Die Y Position der Maus in Pixeln Relativ zur Position des ersten Zeichens
-        __declspec( dllexport ) int textPos( Text *zTxt, int mausX, int mausY ) const;
-
+        __declspec( dllexport ) virtual int textPos( const char *txt, int mausX, int mausY ) const;
         // Erhöht den Reference Counting Zähler.
         //  return: this.
-        __declspec( dllexport ) Schrift *getThis();
-        // Verringert den Reference Counting Zähler. Wenn der Zähler 0 erreicht, wird das Zeichnung automatisch gelöscht.
+        __declspec( dllexport ) TextRenderer *getThis();
+        // Verringert den Reference Counting Zähler. Wenn der Zähler 0 erreicht, wird das Objekt automatisch gelöscht.
         //  return: 0.
-        __declspec( dllexport ) Schrift *release();
+        __declspec( dllexport ) TextRenderer *release();
     };
 }
 

+ 62 - 58
TextFeld.cpp

@@ -20,7 +20,7 @@ using namespace Framework;
 TextFeld::TextFeld()
 	: ZeichnungHintergrund(),
 	schriftSize( 12 ),
-	schrift( 0 ),
+    textRd( 0 ),
 	text( 0 ),
 	sF( 0xFF000000 ),
 	showChar( 0 ),
@@ -40,8 +40,8 @@ TextFeld::TextFeld()
 // Destruktor 
 TextFeld::~TextFeld()
 {
-	if( schrift )
-		schrift->release();
+	if( textRd )
+        textRd->release();
 	if( text )
 		text->release();
 }
@@ -95,14 +95,12 @@ void TextFeld::addZeile( const char *zeile ) // f
 	{
 		Text *txt = new Text( zeile );
 		txt->append( "\n" );
-		if( schrift )
+		if( textRd )
 		{
 			bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
 			int rbr = ( rahmen && hatStyle( Style::Rahmen ) ) ? rahmen->getRBreite() : 0;
-			schrift->lock();
-			schrift->setSchriftSize( schriftSize );
-			schrift->textFormatieren( txt, gr.x - ( (int)vs * 15 ) - rbr * 2, schriftSize );
-			schrift->unlock();
+            textRd->setSchriftSize( schriftSize );
+            textRd->textFormatieren( txt, gr.x - ( (int)vs * 15 ) - rbr * 2 );
 		}
 		lockZeichnung();
 		text->append( txt->getText() );
@@ -132,9 +130,10 @@ void TextFeld::setAuswahl( Punkt &auswahl )
 
 void TextFeld::setSchriftZ( Schrift *schrift ) // setzt einen Zeiger zur Schrift
 {
-	if( this->schrift )
-		this->schrift->release();
-	this->schrift = schrift;
+    if( !this->textRd )
+        textRd = new TextRenderer( schrift );
+    else
+        textRd->setSchriftZ( schrift );
 	rend = 1;
 }
 
@@ -158,13 +157,11 @@ void TextFeld::setSchowChar( unsigned char c ) // bei Passwortfeld *
 
 void TextFeld::setVScrollZuZeile( int zeile ) // scrollt zur Zeile
 {
-	if( vertikalScrollBar && schrift && text && hatStyle( Style::Mehrzeilig ) )
+	if( vertikalScrollBar && textRd && text && hatStyle( Style::Mehrzeilig ) )
 	{
-		schrift->lock();
-		schrift->setSchriftSize( schriftSize );
+        textRd->setSchriftSize( schriftSize );
 		Text t = "a";
-		vertikalScrollBar->scroll( zeile * ( schrift->getZeilenabstand() + schrift->getTextHeight( &t ) ) );
-		schrift->unlock();
+		vertikalScrollBar->scroll( zeile * ( textRd->getZeilenabstand() + textRd->getTextHeight( t ) ) );
 		rend = 1;
 	}
 }
@@ -177,19 +174,19 @@ void TextFeld::updateVScroll( int pos ) // scrollt nach unten
 	{
 		int sPos = 0;
 		int hi = 0;
-		if( text && schrift )
+		if( text && textRd )
 		{
 			if( hatStyleNicht( Style::Mehrzeilig ) )
 				text->remove( '\n' );
-			schrift->setSchriftSize( schriftSize );
+            textRd->setSchriftSize( schriftSize );
 			hi = gr.y;
 			if( hatStyle( Style::Rahmen ) && rahmen )
 				hi -= rahmen->getRBreite() * 2;
 			if( hatStyle( Style::HScroll ) && horizontalScrollBar )
 				hi -= 15;
-			vertikalScrollBar->update( schrift->getTextHeight( text ) + schriftSize + schrift->getTextHeight( Text( "a" ).getThis() ), hi );
+			vertikalScrollBar->update( textRd->getTextHeight( text->getText() ) + schriftSize + textRd->getTextHeight( "a" ), hi );
 			Text t;
-			int zh = schrift->getTextHeight( &t ) + schrift->getZeilenabstand();
+			int zh = textRd->getTextHeight( t ) + textRd->getZeilenabstand();
 			int l = text->getLength();
 			for( int i = 0; i < l && ( i < pos || hatStyleNicht( Style::Erlaubt ) ); ++i )
 			{
@@ -197,12 +194,12 @@ void TextFeld::updateVScroll( int pos ) // scrollt nach unten
 					sPos += zh;
 			}
 		}
-		if( schrift )
+		if( textRd )
 		{
-			if( sPos - schrift->getZeilenabstand() - schrift->getTextHeight( Text( "a" ).getThis() ) < vertikalScrollBar->getScroll() )
-				vertikalScrollBar->scroll( sPos - schrift->getZeilenabstand() - schrift->getTextHeight( Text( "a" ).getThis() ) );
-			if( sPos + schrift->getZeilenabstand() + schrift->getTextHeight( Text( "a" ).getThis() ) > vertikalScrollBar->getScroll() + vertikalScrollBar->getScrollData()->anzeige )
-				vertikalScrollBar->scroll( sPos + ( schrift->getZeilenabstand() + schrift->getTextHeight( Text( "a" ).getThis() ) ) * 2 - hi );
+			if( sPos - textRd->getZeilenabstand() - textRd->getTextHeight( "a" ) < vertikalScrollBar->getScroll() )
+				vertikalScrollBar->scroll( sPos - textRd->getZeilenabstand() - textRd->getTextHeight( "a" ) );
+			if( sPos + textRd->getZeilenabstand() + textRd->getTextHeight( "a" ) > vertikalScrollBar->getScroll() + vertikalScrollBar->getScrollData()->anzeige )
+				vertikalScrollBar->scroll( sPos + ( textRd->getZeilenabstand() + textRd->getTextHeight( "a" ) ) * 2 - hi );
 		}
 		rend = 1;
 	}
@@ -212,16 +209,15 @@ void TextFeld::updateHScroll( int pos ) // scrollt zur Curser Position
 {
 	if( pos == -1 )
 		pos = cpos;
-	if( horizontalScrollBar && text && schrift )
+	if( horizontalScrollBar && text && textRd )
 	{
-		schrift->lock();
-		schrift->setSchriftSize( schriftSize );
+        textRd->setSchriftSize( schriftSize );
 		int br = gr.x;
 		if( hatStyle( Style::Rahmen ) && rahmen )
 			br -= rahmen->getRBreite() * 2;
 		if( hatStyle( Style::VScroll ) && vertikalScrollBar )
 			br -= 15;
-		int maxBr = schrift->getTextBreite( text ) + schriftSize;
+		int maxBr = textRd->getTextBreite( text->getText() ) + schriftSize;
 		horizontalScrollBar->update( maxBr, br );
 		if( hatStyle( Style::Erlaubt ) && maxBr > br && pos > 0 && pos < text->getLength() )
 		{
@@ -233,14 +229,13 @@ void TextFeld::updateHScroll( int pos ) // scrollt zur Curser Position
 					p1 = i + 1;
 			}
 			Text *t = text->getTeilText( p1, pos );
-			int cbr = schrift->getTextBreite( t );
+			int cbr = textRd->getTextBreite( t->getText() );
 			t->release();
 			if( cbr + schriftSize > horizontalScrollBar->getScroll() + horizontalScrollBar->getScrollData()->anzeige )
 				horizontalScrollBar->scroll( cbr + schriftSize - br );
 			if( cbr - schriftSize < horizontalScrollBar->getScroll() )
 				horizontalScrollBar->scroll( cbr - schriftSize );
 		}
-		schrift->unlock();
 	}
 }
 
@@ -366,14 +361,14 @@ void TextFeld::doMausEreignis( MausEreignis &me ) // Maus Ereignis
 			}
 			if( me.mx < gr.x - rbr - 15 )
 			{
-				if( schrift )
+				if( textRd )
 				{
-					schrift->setSchriftSize( schriftSize );
+                    textRd->setSchriftSize( schriftSize );
 					bool shift = TastenStand[ T_Shift ];
 					if( me.id == Framework::ME_PLinks )
 					{
-						int tbr = schrift->getTextBreite( text );
-						int thi = schrift->getTextHeight( text );
+						int tbr = textRd->getTextBreite( text->getText() );
+						int thi = textRd->getTextHeight( text->getText() );
 						int scrollHi = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? vertikalScrollBar->getScroll() : 0;
 						int scrollBr = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ? horizontalScrollBar->getScroll() : 0;
 						int xxx = me.mx - rbr + scrollBr;
@@ -383,7 +378,7 @@ void TextFeld::doMausEreignis( MausEreignis &me ) // Maus Ereignis
 							xxx -= ( ( ( gr.x - scrollBreite ) / 2 ) - tbr / 2 ) - rbr;
 						if( hatStyle( Style::VCenter ) && hatStyleNicht( Style::VScroll ) )
 							yyy -= ( ( ( gr.y - scrollHi ) / 2 ) - thi / 2 ) - rbr;
-						int pos = schrift->textPos( text, xxx, yyy );
+						int pos = textRd->textPos( text->getText(), xxx, yyy );
 						if( pos != -1 )
 						{
 							if( shift )
@@ -403,8 +398,8 @@ void TextFeld::doMausEreignis( MausEreignis &me ) // Maus Ereignis
 					}
 					if( me.id == ME_Bewegung && mausKlick )
 					{
-						int tbr = schrift->getTextBreite( text );
-						int thi = schrift->getTextHeight( text );
+						int tbr = textRd->getTextBreite( text->getText() );
+						int thi = textRd->getTextHeight( text->getText() );
 						int scrollHi = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? vertikalScrollBar->getScroll() : 0;
 						int scrollBr = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ? horizontalScrollBar->getScroll() : 0;
 						int xxx = me.mx - rbr + scrollBr;
@@ -415,7 +410,7 @@ void TextFeld::doMausEreignis( MausEreignis &me ) // Maus Ereignis
 							xxx -= ( ( ( gr.x - scrollBreite ) / 2 ) - tbr / 2 ) - rbr;
 						if( hatStyle( Style::VCenter ) && hatStyleNicht( Style::VScroll ) )
 							yyy -= ( ( ( gr.y - scrollHeight ) / 2 ) - thi / 2 ) - rbr;
-						int pos = schrift->textPos( text, xxx, yyy );
+						int pos = textRd->textPos( text->getText(), xxx, yyy );
 						if( pos != -1 )
 						{
 							if( begf != pos )
@@ -431,8 +426,8 @@ void TextFeld::doMausEreignis( MausEreignis &me ) // Maus Ereignis
 					{
 						if( !shift )
 						{
-							int tbr = schrift->getTextBreite( text );
-							int thi = schrift->getTextHeight( text );
+							int tbr = textRd->getTextBreite( text->getText() );
+							int thi = textRd->getTextHeight( text->getText() );
 							int scrollHi = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? vertikalScrollBar->getScroll() : 0;
 							int scrollBr = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ? horizontalScrollBar->getScroll() : 0;
 							int xxx = me.mx - rbr + scrollBr;
@@ -443,7 +438,7 @@ void TextFeld::doMausEreignis( MausEreignis &me ) // Maus Ereignis
 								xxx -= ( ( ( gr.x - scrollBreite ) / 2 ) - tbr / 2 ) - rbr;
 							if( hatStyle( Style::VCenter ) && hatStyleNicht( Style::VScroll ) )
 								yyy -= ( ( ( gr.y - scrollHeight ) / 2 ) - thi / 2 ) - rbr;
-							int pos = schrift->textPos( text, xxx, yyy );
+							int pos = textRd->textPos( text->getText(), xxx, yyy );
 							if( pos != -1 )
 							{
 								begf = pos;
@@ -663,7 +658,7 @@ void TextFeld::render( Bild &zRObj ) // zeichenet nach zRObj
 	if( hatStyleNicht( Style::Sichtbar ) )
 		return;
 	ZeichnungHintergrund::render( zRObj );
-	if( !text || !schrift )
+	if( !text || !textRd )
 		return;
 	lockZeichnung();
 	if( !zRObj.setDrawOptions( innenPosition, innenSize ) )
@@ -678,9 +673,9 @@ void TextFeld::render( Bild &zRObj ) // zeichenet nach zRObj
 		while( text->hat( '\r' ) )
 			text->remove( text->positionVon( '\r' ), text->positionVon( '\r' ) + 11 );
 	}
-	schrift->setSchriftSize( schriftSize );
-	int tbr = schrift->getTextBreite( text );
-	int thi = schrift->getTextHeight( text );
+    textRd->setSchriftSize( schriftSize );
+	int tbr = textRd->getTextBreite( text->getText() );
+	int thi = textRd->getTextHeight( text->getText() );
 	int xxx = 0;
 	int yyy = 0;
 	int breite = innenSize.x;
@@ -695,7 +690,6 @@ void TextFeld::render( Bild &zRObj ) // zeichenet nach zRObj
 		xxx = ( breite / 2 ) - tbr / 2;
 	if( hatStyle( Style::VCenter ) && !vs )
 		yyy = ( height / 2 ) - thi / 2;
-	schrift->setDrawPosition( xxx, yyy );
 	if( hatStyle( Style::Fokus ) && hatStyle( Style::Erlaubt ) )
 	{
 		if( istSchreibbar( showChar ) )
@@ -704,16 +698,16 @@ void TextFeld::render( Bild &zRObj ) // zeichenet nach zRObj
 			int len = text->getLength() - text->anzahlVon( '\n' ) - text->anzahlVon( '\r' ) * 11;
 			rt.fillText( showChar, len );
 			if( tickVal <= 0.5 )
-				schrift->renderText( &rt, zRObj, cpos, 0xFFFF5555, begf, 0xFF0000FF, sF );
+                textRd->renderText( xxx, yyy, rt, zRObj, cpos, 0xFFFF5555, begf, 0xFF0000FF, sF );
 			else
-				schrift->renderText( &rt, zRObj, cpos, 0x00000000, begf, 0xFF0000FF, sF );
+                textRd->renderText( xxx, yyy, rt, zRObj, cpos, 0x00000000, begf, 0xFF0000FF, sF );
 		}
 		else
 		{
 			if( tickVal <= 0.5 )
-				schrift->renderText( text, zRObj, cpos, 0xFFFF5555, begf, 0xFF0000FF, sF );
+                textRd->renderText( xxx, yyy, text->getText(), zRObj, cpos, 0xFFFF5555, begf, 0xFF0000FF, sF );
 			else
-				schrift->renderText( text, zRObj, cpos, 0x00000000, begf, 0xFF0000FF, sF );
+                textRd->renderText( xxx, yyy, text->getText(), zRObj, cpos, 0x00000000, begf, 0xFF0000FF, sF );
 		}
 	}
 	else
@@ -723,10 +717,10 @@ void TextFeld::render( Bild &zRObj ) // zeichenet nach zRObj
 			Text rt;
 			int len = text->getLength() - text->anzahlVon( '\n' ) - text->anzahlVon( '\r' ) * 11;
 			rt.fillText( showChar, len );
-			schrift->renderText( &rt, zRObj, sF );
+            textRd->renderText( xxx, yyy, rt, zRObj, sF );
 		}
 		else
-			schrift->renderText( text, zRObj, sF );
+            textRd->renderText( xxx, yyy, text->getText(), zRObj, sF );
 	}
 	zRObj.releaseDrawOptions();
 	unlockZeichnung();
@@ -747,14 +741,24 @@ Text *TextFeld::zText() const // gibt den Text zur
 
 Schrift *TextFeld::getSchrift() const// gint getThis der Schrift Zurück
 {
-	if( !schrift )
+	if( !textRd )
 		return 0;
-	return schrift->getThis();
+	return textRd->getSchrift();
 }
 
 Schrift *TextFeld::zSchrift() const// gibt die Schrift zurück
 {
-	return schrift;
+	return textRd ? textRd->zSchrift() : 0;
+}
+
+TextRenderer *TextFeld::getTextRenderer() const
+{
+    return textRd ? textRd->getThis() : 0;
+}
+
+TextRenderer *TextFeld::zTextRenderer() const
+{
+    return textRd;
 }
 
 unsigned char TextFeld::getSchriftSize() const // gibt die Schriftgröße zurück
@@ -795,8 +799,8 @@ Zeichnung *TextFeld::dublizieren() const // Erzeugt eine Kopie des Zeichnungs
 		obj->setToolTipText( toolTip->zText()->getText(), toolTip->zBildschirm() );
 	obj->setStyle( style );
 	obj->setSchriftSize( schriftSize );
-	if( schrift )
-		obj->setSchriftZ( schrift->getThis() );
+	if( textRd )
+		obj->setSchriftZ( textRd->getSchrift() );
 	if( text )
 		obj->setText( text->getText() );
 	obj->setHintergrundFarbe( hintergrundFarbe );

+ 11 - 1
TextFeld.h

@@ -12,6 +12,7 @@ namespace Framework
     class TextFeld; // aus dieser Datei
     class VScrollBar; // Scroll.h
     class HScrollBar; // Scroll.h
+    class TextRenderer;
 
     // Verwaltet ein Textfeld
     class TextFeld : public ZeichnungHintergrund
@@ -33,7 +34,7 @@ namespace Framework
         };
     private:
         unsigned char schriftSize;
-        Schrift *schrift;
+        TextRenderer *textRd;
         Text *text;
         int sF;
         unsigned char showChar;
@@ -67,6 +68,9 @@ namespace Framework
         // Setzt den ausgewählten textabschnitt fest (benötigt Flag zum Zeichnen: Erlaubt, Fokus)
         //  auswahl: Ein punkt mit x als Cursorposition und y als der Position, bis zu der der Text eingefärbt werden soll
         __declspec( dllexport ) void setAuswahl( Punkt &auswahl );
+        // Setzt den verwendeten TextRenderer
+        //  textRd: Der Textrenderer
+        __declspec( dllexport ) void setTextRendererZ( TextRenderer *textRd );
         // Setzt einen Zeiger zur Schrift
         //  schrift: Die Schrift, die zum Textzeichnen verwendet werden soll.
         __declspec( dllexport ) void setSchriftZ( Schrift *schrift );
@@ -112,6 +116,12 @@ namespace Framework
         // Gibt die Schrift ohne erhöhten Reference Counter zurük
         //  return: 0, falls die Schrift nicht gesetzt wurde
         __declspec( dllexport ) Schrift *zSchrift() const;
+        // Gibt den TextRenderer zurück.
+        //  return: 0, falls der TextRenderer nicht gesetzt wurde
+        __declspec( dllexport ) TextRenderer *getTextRenderer() const;
+        // Gibt dien TextRenderer ohne erhöhten Reference Counter zurük
+        //  return: 0, falls der TextRenderer nicht gesetzt wurde
+        __declspec( dllexport ) TextRenderer *zTextRenderer() const;
         // Gibt die Schriftgröße zurück
         __declspec( dllexport ) unsigned char getSchriftSize() const;
         // Gibt die Schriftfarbe im A8R8G8B8 Format zurück

+ 2 - 4
ToolTip.cpp

@@ -142,10 +142,8 @@ void ToolTip::render( Bild &zRObj )
 {
     if( alpha && zeichnen )
     {
-        zSchrift()->lock();
-        zSchrift()->setSchriftSize( getSchriftSize() );
-        size = Punkt( zSchrift()->getTextBreite( zText() ) + getRahmenBreite() * 2, zSchrift()->getTextHeight( zText() ) + getRahmenBreite() * 2 );
-        zSchrift()->unlock();
+        zTextRenderer()->setSchriftSize( getSchriftSize() );
+        size = Punkt( zTextRenderer()->getTextBreite( zText()->getText() ) + getRahmenBreite() * 2, zTextRenderer()->getTextHeight( zText()->getText() ) + getRahmenBreite() * 2 );
         zRObj.setAlpha( alpha );
         setPosition( pos );
         if( getX() + getBreite() > zRObj.getBreite() )