Browse Source

Fehler behoben

Kolja Strohm 5 years ago
parent
commit
f119493de6
2 changed files with 94 additions and 58 deletions
  1. 12 9
      Knopf.cpp
  2. 82 49
      TextFeld.cpp

+ 12 - 9
Knopf.cpp

@@ -593,7 +593,7 @@ void KontrollKnopf::doMausEreignis( MausEreignis &me ) // Nachrichten verarbeitu
             toolTip->setMausIn( 0 );
         return;
     }
-    if( !mausIn && me.id != ME_Leaves )
+    if( !mausIn && me.id != ME_Leaves && !me.verarbeitet )
     {
         mausIn = 1;
         if( toolTip )
@@ -615,16 +615,19 @@ void KontrollKnopf::doMausEreignis( MausEreignis &me ) // Nachrichten verarbeitu
     me.my -= pos.y;
     if( mak && ( me.verarbeitet || mak( makParam, this, me ) ) )
     {
-        if( me.id == ME_Betritt && hatStyle( Style::MausKlick ) != MausStand[ M_Links ] )
-            setStyle( Style::MausKlick, MausStand[ M_Links ] );
-        if( !me.verarbeitet && me.id == ME_PLinks )
-            addStyle( Style::MausKlick );
-        if( me.id == ME_RLinks )
+        if( !me.verarbeitet )
         {
-            removeStyle( Style::MausKlick );
-            setStyle( Style::Selected, !hatStyle( Style::Selected ) );
+            if( me.id == ME_Betritt && hatStyle( Style::MausKlick ) != MausStand[ M_Links ] )
+                setStyle( Style::MausKlick, MausStand[ M_Links ] );
+            if( !me.verarbeitet && me.id == ME_PLinks )
+                addStyle( Style::MausKlick );
+            if( me.id == ME_RLinks )
+            {
+                removeStyle( Style::MausKlick );
+                setStyle( Style::Selected, !hatStyle( Style::Selected ) );
+            }
+            me.verarbeitet = 1;
         }
-        me.verarbeitet = 1;
     }
     if( nmakc && me.verarbeitet && nMak )
         me.verarbeitet = nMak( nmakParam, this, me );

+ 82 - 49
TextFeld.cpp

@@ -500,49 +500,22 @@ void TextFeld::addLineBreaks()
     Text result = "";
     int len = tm->text->getLength();
     lockZeichnung();
+    int maxBr = getBreite();
+    if( hatStyle( Style::VScroll ) && vertikalScrollBar )
+        maxBr -= 15;
     tm->resetIteration();
-    TextStyle last = tm->currentStyle();
+    TextStyle last;
+    last.beginIndex = 0;
+    last.fontColor = 0xFFFFFFFF;
+    last.fontSize = 12;
+    last.selected = 0;
+    last.selectedColor = 0xFFFFFFFF;
+    last.selectedBackcroundColor = 0xFF0000FF;
+    last.underlined = 0;
+    last.interactParam = 0;
+    last.rendererIndex = 0;
     for( int i = 0; i < len; ++i )
     {
-        if( txt[ i ] == ' ' )
-        {
-            lastPos = i;
-            lastPos2 = result.getLength();
-            x += tm->zCurrentRenderer()->getTextBreite( " " );
-            result += " ";
-            continue;
-        }
-        if( txt[ i ] == '\t' )
-        {
-            lastPos = i;
-            lastPos2 = result.getLength();
-            x += tm->zCurrentRenderer()->getTextBreite( "\t" );
-            result += "\t";
-            continue;
-        }
-        if( txt[ i ] == '\n' )
-        {
-            x = 0;
-            lastPos = -1;
-            lastPos2 = -1;
-            result += "\n";
-            continue;
-        }
-        char buff[ 2 ] = { txt[ i ], 0 };
-        x += tm->zCurrentRenderer()->getTextBreite( buff );
-        result += buff;
-        if( x > getBreite() && lastPos > -1 )
-        {
-            result.remove( lastPos2, result.getLength() );
-            result += "\n";
-            x = 0;
-            i = lastPos;
-            lastPos = -1;
-            lastPos2 = -1;
-            tm->stepTo( lastPos );
-            last = tm->currentStyle();
-        }
-        tm->nextStyle();
         if( last.fontSize != tm->current.fontSize )
         {
             char tmp[ 3 ] = { 2, (char)tm->current.fontSize, 0 };
@@ -551,7 +524,7 @@ void TextFeld::addLineBreaks()
         }
         if( last.fontColor != tm->current.fontColor )
         {
-            char tmp[ 6 ] = { 3, (char)((tm->current.fontColor >> 24) & 0xFF), 
+            char tmp[ 6 ] = { 3, (char)( ( tm->current.fontColor >> 24 ) & 0xFF ),
                 (char)( ( tm->current.fontColor >> 16 ) & 0xFF ),
                 (char)( ( tm->current.fontColor >> 8 ) & 0xFF ),
                 (char)( tm->current.fontColor & 0xFF ), 0 };
@@ -597,6 +570,48 @@ void TextFeld::addLineBreaks()
             result += tmp;
             last.rendererIndex = tm->current.rendererIndex;
         }
+        if( txt[ i ] == ' ' )
+        {
+            lastPos = i;
+            lastPos2 = result.getLength();
+            x += tm->zCurrentRenderer()->getTextBreite( " " );
+            result += " ";
+            tm->nextStyle();
+            continue;
+        }
+        if( txt[ i ] == '\t' )
+        {
+            lastPos = i;
+            lastPos2 = result.getLength();
+            x += tm->zCurrentRenderer()->getTextBreite( "\t" );
+            result += "\t";
+            tm->nextStyle();
+            continue;
+        }
+        if( txt[ i ] == '\n' )
+        {
+            x = 0;
+            lastPos = -1;
+            lastPos2 = -1;
+            result += "\n";
+            tm->nextStyle();
+            continue;
+        }
+        char buff[ 2 ] = { txt[ i ], 0 };
+        x += tm->zCurrentRenderer()->getTextBreite( buff );
+        result += buff;
+        if( x > maxBr && lastPos > -1 )
+        {
+            result.remove( lastPos2, result.getLength() );
+            result += "\n";
+            x = 0;
+            i = lastPos;
+            tm->stepTo( lastPos );
+            lastPos = -1;
+            lastPos2 = -1;
+            last = tm->currentStyle();
+        }
+        tm->nextStyle();
     }
     unlockZeichnung();
     setFormattedText( result );
@@ -1050,9 +1065,9 @@ void TextFeld::doMausEreignis( MausEreignis & me ) // Maus Ereignis
     bool nmakc = !me.verarbeitet;
     if( hatStyleNicht( Style::Erlaubt ) || hatStyleNicht( Style::Sichtbar ) )
     {
+        me.mx -= pos.x, me.my -= pos.y;
         if( toolTip )
             toolTip->setMausIn( 0 );
-        me.mx -= pos.x, me.my -= pos.y;
         int rbr = 0;
         if( rahmen )
             rbr = rahmen->getRBreite();
@@ -1061,9 +1076,26 @@ void TextFeld::doMausEreignis( MausEreignis & me ) // Maus Ereignis
             me.mx > rbr && me.mx < gr.x - rbr &&
             me.my > rbr && me.my < gr.y - rbr )
         {
-            vertikalScrollBar->doMausMessage( gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me );
-            horizontalScrollBar->doMausMessage( rbr, gr.y - rbr * 2 - 15, gr.x - rbr * 2 - ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? 15 : 0 ), 15, me );
-            me.verarbeitet = 1;
+            me.verarbeitet |= vertikalScrollBar->doMausMessage( gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me );
+            me.verarbeitet |= horizontalScrollBar->doMausMessage( rbr, gr.y - rbr * 2 - 15, gr.x - rbr * 2 - ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? 15 : 0 ), 15, me );
+        }
+        if( me.mx >= 0 && me.mx <= gr.x && me.my >= 0 && me.my <= gr.y && !me.verarbeitet && hatStyle( Style::Sichtbar )  )
+        {
+            if( mak && mak( makParam, this, me ) )
+            {
+                int scrollHi = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? vertikalScrollBar->getScroll() : 0;
+                int scrollBr = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ? horizontalScrollBar->getScroll() : 0;
+                int xxx = me.mx - rbr + scrollBr;
+                int yyy = me.my - rbr + scrollHi;
+                int mausChar = getTextIndexAt( xxx, yyy );
+                if( mausChar >= 0 )
+                {
+                    TextStyle s = tm->getTextStyle( mausChar );
+                    if( charEvent && s.interactParam )
+                        charEvent( mausChar, s.interactParam, me );
+                }
+                me.verarbeitet = 1;
+            }
         }
         me.mx += pos.x, me.my += pos.y;
         mausKlick = 0;
@@ -1674,13 +1706,14 @@ int TextFeld::getTextIndexAt( int mx, int my ) const
     int maxLH = 0;
     for( int i = 0; i < len; i++ )
     {
-        int tmpx = tm->zCurrentRenderer()->getCharWidth( istSchreibbar( showChar ) ? showChar : text[ i ] );
+        char buff[ 2 ] = { istSchreibbar( showChar ) ? showChar : text[ i ], 0 };
+        int tmpx = tm->zCurrentRenderer()->getTextBreite( buff );
         int tmpy = tm->zCurrentRenderer()->getZeilenHeight();
-        if( mx >= x && mx < x + tmpx && my >= y && my < maxLH + tmpy )
+        if( mx >= x && mx < x + tmpx && my >= y && my < y + tmpy )
             return i;
-        if( mx < x + tmpx && my < maxLH + tmpy )
+        if( mx < x + tmpx && my < y + tmpy )
             return -1;
-        x += tmpx + tm->zCurrentRenderer()->getZeichenAbstand();
+        x += tmpx;
         tmpy += tm->zCurrentRenderer()->getZeilenAbstand();
         maxLH = tmpy > maxLH ? tmpy : maxLH;
         if( text[ i ] == '\n' )