|
@@ -15,821 +15,1475 @@
|
|
|
|
|
|
using namespace Framework;
|
|
|
|
|
|
+template<typename T, typename... U>
|
|
|
+size_t getAddress( std::function<T( U... )> f )
|
|
|
+{
|
|
|
+ typedef T( fnType )( U... );
|
|
|
+ fnType ** fnPointer = f.template target<fnType*>();
|
|
|
+ if( !fnPointer )
|
|
|
+ return 0;
|
|
|
+ return (size_t)*fnPointer;
|
|
|
+}
|
|
|
+
|
|
|
+bool TextFeld::TextStyle::operator==( const TextStyle& rhs )
|
|
|
+{
|
|
|
+ return fontSize == rhs.fontSize && fontColor == rhs.fontColor &&
|
|
|
+ selectedColor == rhs.selectedColor && selectedBackcroundColor == rhs.selectedBackcroundColor &&
|
|
|
+ underlined == rhs.underlined && selected == rhs.selected && getAddress( onClick ) == getAddress( rhs.onClick ) && rendererIndex == rhs.rendererIndex;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+TextFeld::TextStyleManager::TextStyleManager()
|
|
|
+ : renderer( new RCArray< TextRenderer >() ),
|
|
|
+ index( 0 ),
|
|
|
+ styleIndex( 0 ),
|
|
|
+ text( 0 ),
|
|
|
+ ref( 1 )
|
|
|
+{
|
|
|
+ current.beginIndex = 0;
|
|
|
+ current.fontColor = 0xFFFFFFFF;
|
|
|
+ current.fontSize = 12;
|
|
|
+ current.selected = 0;
|
|
|
+ current.selectedColor = 0xFFFFFFFF;
|
|
|
+ current.selectedBackcroundColor = 0xFF0000FF;
|
|
|
+ current.underlined = 0;
|
|
|
+ current.onClick = 0;
|
|
|
+ current.rendererIndex = 0;
|
|
|
+ textStyle.add( current );
|
|
|
+}
|
|
|
+
|
|
|
+TextFeld::TextStyleManager::~TextStyleManager()
|
|
|
+{
|
|
|
+ if( renderer )
|
|
|
+ renderer->release();
|
|
|
+ if( text )
|
|
|
+ text->release();
|
|
|
+}
|
|
|
+
|
|
|
+// Setzt den Style eines Textabschnittes
|
|
|
+// begin: die startposition des Abschnittes
|
|
|
+// end: die endposition des Abschnittes (nicht enthalten)
|
|
|
+void TextFeld::TextStyleManager::setTextStyle( int begin, int end, TextFeld::TextStyle style )
|
|
|
+{
|
|
|
+ if( begin < 0 || begin > end || begin > text->getLength() )
|
|
|
+ return;
|
|
|
+ int sc = textStyle.getEintragAnzahl();
|
|
|
+ int index = -1;
|
|
|
+ TextStyle s = textStyle.get( 0 );
|
|
|
+ // suche bis zur richtigen stelle im stylearray
|
|
|
+ for( int i = 0; i < sc; i++ )
|
|
|
+ {
|
|
|
+ if( textStyle.get( i ).beginIndex >= begin )
|
|
|
+ {
|
|
|
+ index = i;
|
|
|
+ if( textStyle.get( i ).beginIndex > begin )
|
|
|
+ s = textStyle.get( i - 1 );
|
|
|
+ else
|
|
|
+ {
|
|
|
+ s = textStyle.get( i );
|
|
|
+ textStyle.remove( i );
|
|
|
+ sc--;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ style.beginIndex = begin;
|
|
|
+ s.beginIndex = end;
|
|
|
+ if( index < 0 )
|
|
|
+ { // hinten an styles anfügen
|
|
|
+ textStyle.add( style );
|
|
|
+ textStyle.add( s );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ { // in die mitte des style arrays einfügen
|
|
|
+ textStyle.add( style, index );
|
|
|
+ for( int i = index + 1; i < sc + 1; i++ )
|
|
|
+ { // styles entfernen die überschrieben wurden
|
|
|
+ if( textStyle.get( i ).beginIndex <= end && textStyle.get( i ).beginIndex > begin )
|
|
|
+ {
|
|
|
+ s = textStyle.get( i );
|
|
|
+ textStyle.remove( i );
|
|
|
+ i--;
|
|
|
+ sc--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ s.beginIndex = end;
|
|
|
+ textStyle.add( s, index + 1 );
|
|
|
+ }
|
|
|
+ cleanupStyles();
|
|
|
+}
|
|
|
+
|
|
|
+// Entfernt einen Textabschnitt
|
|
|
+// begin: der index des ersten betroffenen zeichens
|
|
|
+// end: der index des ersten zeichens nach dem abschnitt
|
|
|
+void TextFeld::TextStyleManager::removeText( int begin, int end )
|
|
|
+{
|
|
|
+ int sc = textStyle.getEintragAnzahl();
|
|
|
+ for( int i = 0; i < sc; i++ )
|
|
|
+ {
|
|
|
+ TextStyle s = textStyle.get( i );
|
|
|
+ if( s.beginIndex >= begin && s.beginIndex < end )
|
|
|
+ {
|
|
|
+ textStyle.remove( i );
|
|
|
+ i--;
|
|
|
+ sc--;
|
|
|
+ }
|
|
|
+ if( s.beginIndex >= end )
|
|
|
+ {
|
|
|
+ s.beginIndex -= end - begin;
|
|
|
+ textStyle.set( s, i );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ text->remove( begin, end );
|
|
|
+ cleanupStyles();
|
|
|
+}
|
|
|
+
|
|
|
+// Fügt ein Text an einer bestimmten Position ein
|
|
|
+// pos: die position des neuen Textausschnitts
|
|
|
+// text: der neue Text
|
|
|
+void TextFeld::TextStyleManager::insertText( int pos, const char *text )
|
|
|
+{
|
|
|
+ int len = textLength( text );
|
|
|
+ this->text->insert( pos, text );
|
|
|
+ int sc = textStyle.getEintragAnzahl();
|
|
|
+ for( int i = 0; i < sc; i++ )
|
|
|
+ {
|
|
|
+ TextStyle s = textStyle.get( i );
|
|
|
+ if( s.beginIndex > pos )
|
|
|
+ {
|
|
|
+ s.beginIndex += len;
|
|
|
+ textStyle.set( s, i );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cleanupStyles();
|
|
|
+}
|
|
|
+
|
|
|
+// Entfernt nicht benötiegte gleiche styles
|
|
|
+void TextFeld::TextStyleManager::cleanupStyles()
|
|
|
+{
|
|
|
+ int sc = textStyle.getEintragAnzahl();
|
|
|
+ TextStyle last = textStyle.get( 0 );
|
|
|
+ for( int i = 1; i < sc; i++ )
|
|
|
+ {
|
|
|
+ if( textStyle.get( i ) == last || ( text && textStyle.get( i ).beginIndex > text->getLength() ) )
|
|
|
+ {
|
|
|
+ textStyle.remove( i );
|
|
|
+ i--;
|
|
|
+ sc--;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ last = textStyle.get( i );
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// gibt eine referenz auf das style objekt zurück
|
|
|
+TextFeld::TextStyle &TextFeld::TextStyleManager::currentStyle()
|
|
|
+{
|
|
|
+ return current;
|
|
|
+}
|
|
|
+
|
|
|
+// gibt den aktuellen text renderer zurück
|
|
|
+TextRenderer *TextFeld::TextStyleManager::zCurrentRenderer()
|
|
|
+{
|
|
|
+ TextRenderer *tr = renderer->z( current.rendererIndex );
|
|
|
+ if( !tr )
|
|
|
+ tr = renderer->z( 0 );
|
|
|
+ if( tr )
|
|
|
+ tr->setSchriftSize( current.fontSize );
|
|
|
+ return tr;
|
|
|
+}
|
|
|
+
|
|
|
+// ändert den inhalt des style objektes auf den style des nächsten zeichens
|
|
|
+bool TextFeld::TextStyleManager::nextStyle()
|
|
|
+{
|
|
|
+ index++;
|
|
|
+ if( textStyle.getEintragAnzahl() > styleIndex + 1 && index >= textStyle.get( styleIndex + 1 ).beginIndex )
|
|
|
+ current = textStyle.get( styleIndex++ + 1 );
|
|
|
+ return text && index < text->getLength();
|
|
|
+}
|
|
|
+
|
|
|
+// ändert den inhalt des style objektes auf den style des ersten zeichens
|
|
|
+void TextFeld::TextStyleManager::resetIteration()
|
|
|
+{
|
|
|
+ index = 0;
|
|
|
+ styleIndex = 0;
|
|
|
+ current = textStyle.get( 0 );
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt den Style eines bestimmten zeichens zurück
|
|
|
+// index: Der index des Zeichensf
|
|
|
+TextFeld::TextStyle TextFeld::TextStyleManager::getTextStyle( int index ) const
|
|
|
+{
|
|
|
+ TextStyle last = textStyle.get( 0 );
|
|
|
+ int ind = 0;
|
|
|
+ for( auto i = textStyle.getIterator(); i && ind <= index; ind++ )
|
|
|
+ {
|
|
|
+ if( i._.beginIndex <= ind )
|
|
|
+ {
|
|
|
+ last = i;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return last;
|
|
|
+}
|
|
|
+
|
|
|
+// Erhöht den Reference Counting Zähler.
|
|
|
+// return: this.
|
|
|
+TextFeld::TextStyleManager *TextFeld::TextStyleManager::getThis()
|
|
|
+{
|
|
|
+ ref++;
|
|
|
+ return this;
|
|
|
+}
|
|
|
+
|
|
|
+// Verringert den Reference Counting Zähler. Wenn der Zähler 0 erreicht, wird das Zeichnung automatisch gelöscht.
|
|
|
+// return: 0.
|
|
|
+TextFeld::TextStyleManager *TextFeld::TextStyleManager::release()
|
|
|
+{
|
|
|
+ if( !--ref )
|
|
|
+ delete this;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
// Inhalt der TextFeld Klasse aus TextFeld.h
|
|
|
// Konstruktor
|
|
|
TextFeld::TextFeld()
|
|
|
- : ZeichnungHintergrund(),
|
|
|
- schriftSize( 12 ),
|
|
|
- textRd( 0 ),
|
|
|
- text( 0 ),
|
|
|
- sF( 0xFF000000 ),
|
|
|
- showChar( 0 ),
|
|
|
- begf( 0 ),
|
|
|
- cpos( 0 ),
|
|
|
- tickVal( 0 ),
|
|
|
- mausKlick( 0 )
|
|
|
-{
|
|
|
- horizontalScrollBar = new HScrollBar();
|
|
|
- vertikalScrollBar = new VScrollBar();
|
|
|
- style = 0;
|
|
|
- this->setMausEreignis( _ret1ME );
|
|
|
- this->setTastaturEreignis( _ret1TE );
|
|
|
+ : ZeichnungHintergrund(),
|
|
|
+ tm( new TextStyleManager() ),
|
|
|
+ showChar( 0 ),
|
|
|
+ cpos( 0 ),
|
|
|
+ tickVal( 0 ),
|
|
|
+ mausKlick( 0 )
|
|
|
+{
|
|
|
+ horizontalScrollBar = new HScrollBar();
|
|
|
+ vertikalScrollBar = new VScrollBar();
|
|
|
+ this->setMausEreignis( _ret1ME );
|
|
|
+ this->setTastaturEreignis( _ret1TE );
|
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
|
TextFeld::~TextFeld()
|
|
|
{
|
|
|
- if( textRd )
|
|
|
- textRd->release();
|
|
|
- if( text )
|
|
|
- text->release();
|
|
|
+ tm->release();
|
|
|
+}
|
|
|
+
|
|
|
+int TextFeld::getTextHeight() const
|
|
|
+{
|
|
|
+ tm->resetIteration();
|
|
|
+ int th = 0;
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ int max = 0;
|
|
|
+ for( int i = 0; i < len; i++ )
|
|
|
+ {
|
|
|
+ if( text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ th += max;
|
|
|
+ max = 0;
|
|
|
+ tm->nextStyle();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TextRenderer *r = tm->zCurrentRenderer();
|
|
|
+ if( r )
|
|
|
+ {
|
|
|
+ int tmp = r->getZeilenabstand() + r->getZeilenHeight();
|
|
|
+ max = max >= tmp ? max : tmp;
|
|
|
+ }
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ if( max > 0 )
|
|
|
+ th += max;
|
|
|
+ return th;
|
|
|
+}
|
|
|
+
|
|
|
+int TextFeld::getTextWidth() const
|
|
|
+{
|
|
|
+ int maxBr = 0;
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ int lineBr = 0;
|
|
|
+ char buff[] = { 0,0 };
|
|
|
+ for( int i = 0; i < len; i++ )
|
|
|
+ {
|
|
|
+ buff[ 0 ] = text[ i ];
|
|
|
+ if( text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ maxBr = maxBr >= lineBr ? maxBr : lineBr;
|
|
|
+ lineBr = 0;
|
|
|
+ tm->nextStyle();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TextRenderer *r = tm->zCurrentRenderer();
|
|
|
+ if( r )
|
|
|
+ lineBr += r->getTextBreite( buff );
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ if( lineBr > 0 )
|
|
|
+ maxBr = maxBr >= lineBr ? maxBr : lineBr;
|
|
|
+ return maxBr;
|
|
|
}
|
|
|
|
|
|
-// nicht constant
|
|
|
void TextFeld::setText( Text *txt ) // setzt den angezeigten Text
|
|
|
{
|
|
|
- lockZeichnung();
|
|
|
- if( !text )
|
|
|
- text = new Text();
|
|
|
- text->setText( txt );
|
|
|
- if( hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll();
|
|
|
- if( hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll();
|
|
|
- unlockZeichnung();
|
|
|
- rend = 1;
|
|
|
+ lockZeichnung();
|
|
|
+ if( !tm->text )
|
|
|
+ tm->text = new Text();
|
|
|
+ tm->text->setText( txt );
|
|
|
+ if( hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll();
|
|
|
+ if( hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll();
|
|
|
+ unlockZeichnung();
|
|
|
+ rend = 1;
|
|
|
}
|
|
|
|
|
|
void TextFeld::setTextZ( Text *txt ) // setzt einen Zeiger zum angezeigten Text
|
|
|
{
|
|
|
- lockZeichnung();
|
|
|
- if( text )
|
|
|
- text->release();
|
|
|
- text = txt;
|
|
|
- if( hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll();
|
|
|
- if( hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll();
|
|
|
- rend = 1;
|
|
|
- unlockZeichnung();
|
|
|
+ lockZeichnung();
|
|
|
+ if( tm->text )
|
|
|
+ tm->text->release();
|
|
|
+ tm->text = txt;
|
|
|
+ if( hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll();
|
|
|
+ if( hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll();
|
|
|
+ rend = 1;
|
|
|
+ unlockZeichnung();
|
|
|
}
|
|
|
|
|
|
void TextFeld::setText( const char *txt ) // setzt den angezeigten Text
|
|
|
{
|
|
|
- lockZeichnung();
|
|
|
- if( !text )
|
|
|
- text = new Text();
|
|
|
- text->setText( txt );
|
|
|
- if( hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll();
|
|
|
- if( hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll();
|
|
|
- rend = 1;
|
|
|
- unlockZeichnung();
|
|
|
+ lockZeichnung();
|
|
|
+ if( !tm->text )
|
|
|
+ tm->text = new Text();
|
|
|
+ tm->text->setText( txt );
|
|
|
+ if( hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll();
|
|
|
+ if( hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll();
|
|
|
+ rend = 1;
|
|
|
+ unlockZeichnung();
|
|
|
+}
|
|
|
+
|
|
|
+// Setzt den Style eines Textabschnittes
|
|
|
+// begin: die startposition des Abschnittes
|
|
|
+// end: die endposition des Abschnittes (nicht enthalten)
|
|
|
+void TextFeld::setTextStyle( int begin, int end, TextStyle style )
|
|
|
+{
|
|
|
+ tm->setTextStyle( begin, end, style );
|
|
|
}
|
|
|
|
|
|
void TextFeld::addZeile( const char *zeile ) // fügt Zeile An
|
|
|
{
|
|
|
- if( text )
|
|
|
- {
|
|
|
- Text *txt = new Text( zeile );
|
|
|
- txt->append( "\n" );
|
|
|
- if( textRd )
|
|
|
- {
|
|
|
- bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
|
|
|
- int rbr = ( rahmen && hatStyle( Style::Rahmen ) ) ? rahmen->getRBreite() : 0;
|
|
|
- textRd->setSchriftSize( schriftSize );
|
|
|
- textRd->textFormatieren( txt, gr.x - ( (int)vs * 15 ) - rbr * 2 );
|
|
|
- }
|
|
|
- lockZeichnung();
|
|
|
- text->append( txt->getText() );
|
|
|
- unlockZeichnung();
|
|
|
- txt->release();
|
|
|
- if( hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll();
|
|
|
- if( hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll();
|
|
|
- rend = 1;
|
|
|
- }
|
|
|
+ if( tm->text )
|
|
|
+ {
|
|
|
+ Text *txt = new Text( zeile );
|
|
|
+ txt->append( "\n" );
|
|
|
+ TextRenderer *r = tm->renderer->z( 0 );
|
|
|
+ if( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).rendererIndex < tm->renderer->getEintragAnzahl() )
|
|
|
+ r = tm->renderer->z( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).rendererIndex );
|
|
|
+ if( r )
|
|
|
+ {
|
|
|
+ bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
|
|
|
+ int rbr = ( rahmen && hatStyle( Style::Rahmen ) ) ? rahmen->getRBreite() : 0;
|
|
|
+ r->setSchriftSize( tm->textStyle.get( tm->textStyle.getEintragAnzahl() - 1 ).fontSize );
|
|
|
+ r->textFormatieren( txt, gr.x - ( (int)vs * 15 ) - rbr * 2 );
|
|
|
+ }
|
|
|
+ lockZeichnung();
|
|
|
+ tm->text->append( txt->getText() );
|
|
|
+ unlockZeichnung();
|
|
|
+ txt->release();
|
|
|
+ if( hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll();
|
|
|
+ if( hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll();
|
|
|
+ rend = 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Deselectiert alle textabschnitte
|
|
|
+void TextFeld::deselectAuswahl()
|
|
|
+{
|
|
|
+ for( int i = 0; i < tm->textStyle.getEintragAnzahl(); i++ )
|
|
|
+ {
|
|
|
+ TextStyle s = tm->textStyle.get( i );
|
|
|
+ if( s.selected )
|
|
|
+ {
|
|
|
+ s.selected = 0;
|
|
|
+ tm->textStyle.set( s, i );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tm->cleanupStyles();
|
|
|
}
|
|
|
|
|
|
void TextFeld::setAuswahl( int pos1, int pos2 ) // setzt den Ausgewählten Text
|
|
|
{
|
|
|
- cpos = pos1;
|
|
|
- begf = pos2;
|
|
|
- rend = 1;
|
|
|
+ deselectAuswahl();
|
|
|
+ TextStyle s = tm->getTextStyle( pos1 );
|
|
|
+ s.selected = 1;
|
|
|
+ tm->setTextStyle( pos1, pos2, s );
|
|
|
}
|
|
|
|
|
|
void TextFeld::setAuswahl( Punkt &auswahl )
|
|
|
{
|
|
|
- cpos = auswahl.x;
|
|
|
- begf = auswahl.y;
|
|
|
- rend = 1;
|
|
|
+ deselectAuswahl();
|
|
|
+ TextStyle s = tm->getTextStyle( auswahl.x );
|
|
|
+ s.selected = 1;
|
|
|
+ tm->setTextStyle( auswahl.x, auswahl.y, s );
|
|
|
+ rend = 1;
|
|
|
+}
|
|
|
+
|
|
|
+void TextFeld::addAuswahl( int pos1, int pos2 )
|
|
|
+{
|
|
|
+ TextStyle s = tm->getTextStyle( pos1 );
|
|
|
+ s.selected = 1;
|
|
|
+ tm->setTextStyle( pos1, pos2, s );
|
|
|
+}
|
|
|
+
|
|
|
+void TextFeld::addAuswahl( Punkt &auswahl )
|
|
|
+{
|
|
|
+ TextStyle s = tm->getTextStyle( auswahl.x );
|
|
|
+ s.selected = 1;
|
|
|
+ tm->setTextStyle( auswahl.x, auswahl.y, s );
|
|
|
+ rend = 1;
|
|
|
+}
|
|
|
+
|
|
|
+// Setzt den ausgewählten textabschnitt fest
|
|
|
+// begin: Die Cursorposition im Text
|
|
|
+// end: Die Position im Text, bis zu der der Text eingefärbt werden soll
|
|
|
+void TextFeld::invertAuswahl( int begin, int end )
|
|
|
+{
|
|
|
+ for( int i = begin; i < end; i++ )
|
|
|
+ {
|
|
|
+ TextStyle s = tm->getTextStyle( i );
|
|
|
+ s.selected = !s.selected;
|
|
|
+ tm->setTextStyle( i, i + 1, s );
|
|
|
+ rend = 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ersetzt alle ausgewählten Textabschnitte mit einem text
|
|
|
+// text: der neue Text
|
|
|
+void TextFeld::replaceAuswahl( const char *text )
|
|
|
+{
|
|
|
+ tm->cleanupStyles();
|
|
|
+ int sa = tm->textStyle.getEintragAnzahl();
|
|
|
+ int last = tm->text->getLength();
|
|
|
+ for( int i = sa - 1; i >= 0; i-- )
|
|
|
+ {
|
|
|
+ TextStyle s = tm->textStyle.get( i );
|
|
|
+ if( s.selected )
|
|
|
+ {
|
|
|
+ if( ( i > 0 && !tm->textStyle.get( i - 1 ).selected ) || i == 0 )
|
|
|
+ {
|
|
|
+ tm->removeText( s.beginIndex, last );
|
|
|
+ tm->insertText( s.beginIndex, text );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ last = s.beginIndex;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void TextFeld::setTextRendererZ( TextRenderer *textRd )
|
|
|
{
|
|
|
- if( this->textRd )
|
|
|
- this->textRd->release();
|
|
|
- this->textRd = textRd;
|
|
|
+ if( tm->renderer )
|
|
|
+ tm->renderer->leeren();
|
|
|
+ else
|
|
|
+ tm->renderer = new RCArray< TextRenderer >();
|
|
|
+ tm->renderer->add( textRd );
|
|
|
+ rend = 1;
|
|
|
+}
|
|
|
+
|
|
|
+// Fügt einen TextRenderer hinzu
|
|
|
+// textRd: Der Textrenderer
|
|
|
+void TextFeld::addTextRendererZ( TextRenderer *textRd )
|
|
|
+{
|
|
|
+ if( !tm->renderer )
|
|
|
+ tm->renderer = new RCArray< TextRenderer >();
|
|
|
+ tm->renderer->add( textRd );
|
|
|
+}
|
|
|
+
|
|
|
+// Setzt die verwendeten TextRenderer
|
|
|
+// textRd: Die Textrenderer
|
|
|
+void TextFeld::setTextRendererZ( RCArray< TextRenderer > *textRd )
|
|
|
+{
|
|
|
+ if( tm->renderer )
|
|
|
+ tm->renderer->release();
|
|
|
+ tm->renderer = textRd;
|
|
|
}
|
|
|
|
|
|
void TextFeld::setSchriftZ( Schrift *schrift ) // setzt einen Zeiger zur Schrift
|
|
|
{
|
|
|
- if( !this->textRd )
|
|
|
- textRd = new TextRenderer( schrift );
|
|
|
+ if( !tm->renderer )
|
|
|
+ tm->renderer = new RCArray< TextRenderer >();
|
|
|
+ if( !tm->renderer->getEintragAnzahl() )
|
|
|
+ tm->renderer->add( new TextRenderer( schrift ) );
|
|
|
+ else
|
|
|
+ tm->renderer->z( 0 )->setSchriftZ( schrift );
|
|
|
+ rend = 1;
|
|
|
+}
|
|
|
+
|
|
|
+// Setzt einen Zeiger zur Schrift
|
|
|
+// rendererIndex: Der Index des Renderers dessen Schrift gesetzt werden soll
|
|
|
+// schrift: Die Schrift, die zum Textzeichnen verwendet werden soll.
|
|
|
+void TextFeld::setSchriftZ( int rendererIndex, Schrift *schrift )
|
|
|
+{
|
|
|
+ if( !tm->renderer )
|
|
|
+ tm->renderer = new RCArray< TextRenderer >();
|
|
|
+ if( tm->renderer->getEintragAnzahl() <= rendererIndex )
|
|
|
+ tm->renderer->add( new TextRenderer( schrift ), rendererIndex );
|
|
|
else
|
|
|
- textRd->setSchriftZ( schrift );
|
|
|
- rend = 1;
|
|
|
+ tm->renderer->z( rendererIndex )->setSchriftZ( schrift );
|
|
|
}
|
|
|
|
|
|
void TextFeld::setSchriftSize( unsigned char gr ) // setzt die Schriftgröße
|
|
|
{
|
|
|
- schriftSize = gr;
|
|
|
- rend = 1;
|
|
|
+ TextStyle s = tm->textStyle.get( 0 );
|
|
|
+ s.fontSize = gr;
|
|
|
+ tm->textStyle.set( s, 0 );
|
|
|
+ rend = 1;
|
|
|
+}
|
|
|
+
|
|
|
+// Setzt die Schriftgröße (Standart: 12)
|
|
|
+// begin: Der Index des ersten betroffenen Zeichens
|
|
|
+// end: Der Index des ersten nicht betroffenen Zeichens
|
|
|
+// gr: Die Schriftgröße, die zum Textzeichnen verwendet werden soll
|
|
|
+void TextFeld::setSchriftSize( int begin, int end, unsigned char gr )
|
|
|
+{
|
|
|
+ TextStyle s = tm->getTextStyle( begin );
|
|
|
+ s.fontSize = gr;
|
|
|
+ tm->setTextStyle( begin, end, s );
|
|
|
+ rend = 1;
|
|
|
}
|
|
|
|
|
|
void TextFeld::setSchriftFarbe( int fc ) // setzt die Schrift Farbe
|
|
|
{
|
|
|
- sF = fc;
|
|
|
- rend = 1;
|
|
|
+ TextStyle s = tm->textStyle.get( 0 );
|
|
|
+ s.fontColor = fc;
|
|
|
+ tm->textStyle.set( s, 0 );
|
|
|
+ rend = 1;
|
|
|
+}
|
|
|
+
|
|
|
+// Setzt die Schrift Farbe
|
|
|
+// begin: Der Index des ersten betroffenen Zeichens
|
|
|
+// end: Der Index des ersten nicht betroffenen Zeichens
|
|
|
+// fc: Die Farbe, die zum Textzeichnen verwendet werden soll
|
|
|
+void TextFeld::setSchriftFarbe( int begin, int end, int fc )
|
|
|
+{
|
|
|
+ TextStyle s = tm->getTextStyle( begin );
|
|
|
+ s.fontColor = fc;
|
|
|
+ tm->setTextStyle( begin, end, s );
|
|
|
+ rend = 1;
|
|
|
}
|
|
|
|
|
|
void TextFeld::setSchowChar( unsigned char c ) // bei Passwortfeld *
|
|
|
{
|
|
|
- showChar = c;
|
|
|
- rend = 1;
|
|
|
+ showChar = c;
|
|
|
+ rend = 1;
|
|
|
}
|
|
|
|
|
|
void TextFeld::setVScrollZuZeile( int zeile ) // scrollt zur Zeile
|
|
|
{
|
|
|
- if( vertikalScrollBar && textRd && text && hatStyle( Style::Mehrzeilig ) )
|
|
|
- {
|
|
|
- textRd->setSchriftSize( schriftSize );
|
|
|
- Text t = "a";
|
|
|
- vertikalScrollBar->scroll( zeile * ( textRd->getZeilenabstand() + textRd->getTextHeight( t ) ) );
|
|
|
- rend = 1;
|
|
|
- }
|
|
|
+ if( vertikalScrollBar && tm->renderer && tm->renderer->getEintragAnzahl() && tm->text && hatStyle( Style::Mehrzeilig ) )
|
|
|
+ {
|
|
|
+ lockZeichnung();
|
|
|
+ tm->resetIteration();
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ int y = 0;
|
|
|
+ int lnum = 0;
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ int max = 0;
|
|
|
+ for( int i = 0; i < len && lnum < zeile; i++ )
|
|
|
+ {
|
|
|
+ if( text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ lnum++;
|
|
|
+ y += max;
|
|
|
+ max = 0;
|
|
|
+ tm->nextStyle();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TextRenderer *r = tm->zCurrentRenderer();
|
|
|
+ if( r )
|
|
|
+ {
|
|
|
+ int tmp = r->getZeilenabstand() + r->getZeilenHeight();
|
|
|
+ max = max >= tmp ? max : tmp;
|
|
|
+ }
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ unlockZeichnung();
|
|
|
+ vertikalScrollBar->scroll( y );
|
|
|
+ rend = 1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void TextFeld::updateVScroll( int pos ) // scrollt nach unten
|
|
|
{
|
|
|
- if( pos == -1 )
|
|
|
- pos = cpos;
|
|
|
- if( vertikalScrollBar )
|
|
|
- {
|
|
|
- int sPos = 0;
|
|
|
- int hi = 0;
|
|
|
- if( text && textRd )
|
|
|
- {
|
|
|
- if( hatStyleNicht( Style::Mehrzeilig ) )
|
|
|
- text->remove( '\n' );
|
|
|
- textRd->setSchriftSize( schriftSize );
|
|
|
- hi = gr.y;
|
|
|
- if( hatStyle( Style::Rahmen ) && rahmen )
|
|
|
- hi -= rahmen->getRBreite() * 2;
|
|
|
- if( hatStyle( Style::HScroll ) && horizontalScrollBar )
|
|
|
- hi -= 15;
|
|
|
- vertikalScrollBar->update( textRd->getTextHeight( text->getText() ) + schriftSize + textRd->getTextHeight( "a" ), hi );
|
|
|
- Text t;
|
|
|
- int zh = textRd->getTextHeight( t ) + textRd->getZeilenabstand();
|
|
|
- int l = text->getLength();
|
|
|
- for( int i = 0; i < l && ( i < pos || hatStyleNicht( Style::Erlaubt ) ); ++i )
|
|
|
- {
|
|
|
- if( text->getText()[ i ] == '\n' )
|
|
|
- sPos += zh;
|
|
|
- }
|
|
|
- }
|
|
|
- if( textRd )
|
|
|
- {
|
|
|
- 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;
|
|
|
- }
|
|
|
+ if( pos == -1 )
|
|
|
+ pos = cpos;
|
|
|
+ if( vertikalScrollBar )
|
|
|
+ {
|
|
|
+ int sPos = 0;
|
|
|
+ int hi = 0;
|
|
|
+ int sPosZH = 0;
|
|
|
+ if( tm->text && tm->renderer )
|
|
|
+ {
|
|
|
+ if( hatStyleNicht( Style::Mehrzeilig ) )
|
|
|
+ tm->text->remove( '\n' );
|
|
|
+ hi = gr.y;
|
|
|
+ if( hatStyle( Style::Rahmen ) && rahmen )
|
|
|
+ hi -= rahmen->getRBreite() * 2;
|
|
|
+ if( hatStyle( Style::HScroll ) && horizontalScrollBar )
|
|
|
+ hi -= 15;
|
|
|
+ int th = 0;
|
|
|
+ lockZeichnung();
|
|
|
+ tm->resetIteration();
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ int max = 0;
|
|
|
+ int lastMax = 0;
|
|
|
+ for( int i = 0; i < len; i++ )
|
|
|
+ {
|
|
|
+ if( text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ if( i <= pos )
|
|
|
+ {
|
|
|
+ sPos += max;
|
|
|
+ sPosZH = max;
|
|
|
+ }
|
|
|
+ th += max;
|
|
|
+ lastMax = max;
|
|
|
+ max = 0;
|
|
|
+ tm->nextStyle();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TextRenderer *r = tm->zCurrentRenderer();
|
|
|
+ if( r )
|
|
|
+ {
|
|
|
+ int tmp = r->getZeilenabstand() + r->getZeilenHeight();
|
|
|
+ max = max >= tmp ? max : tmp;
|
|
|
+ }
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ if( max != lastMax && max > 0 )
|
|
|
+ {
|
|
|
+ th += max;
|
|
|
+ lastMax = max;
|
|
|
+ }
|
|
|
+ th += lastMax;
|
|
|
+ unlockZeichnung();
|
|
|
+ vertikalScrollBar->update( th, hi );
|
|
|
+ }
|
|
|
+ if( sPos - sPosZH < vertikalScrollBar->getScroll() )
|
|
|
+ vertikalScrollBar->scroll( sPos - sPosZH );
|
|
|
+ if( sPos + sPosZH > vertikalScrollBar->getScroll() + vertikalScrollBar->getScrollData()->anzeige )
|
|
|
+ vertikalScrollBar->scroll( sPos + sPosZH * 2 - hi );
|
|
|
+ rend = 1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void TextFeld::updateHScroll( int pos ) // scrollt zur Curser Position
|
|
|
{
|
|
|
- if( pos == -1 )
|
|
|
- pos = cpos;
|
|
|
- if( horizontalScrollBar && text && textRd )
|
|
|
- {
|
|
|
- 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 = textRd->getTextBreite( text->getText() ) + schriftSize;
|
|
|
- horizontalScrollBar->update( maxBr, br );
|
|
|
- if( hatStyle( Style::Erlaubt ) && maxBr > br && pos > 0 && pos < text->getLength() )
|
|
|
- {
|
|
|
- int p1 = 0;
|
|
|
- char *tmp = text->getText();
|
|
|
- for( int i = 0; i < pos; i++, tmp++ )
|
|
|
- {
|
|
|
- if( *tmp == '\n' )
|
|
|
- p1 = i + 1;
|
|
|
- }
|
|
|
- Text *t = text->getTeilText( p1, pos );
|
|
|
- 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 );
|
|
|
- }
|
|
|
- }
|
|
|
+ if( pos == -1 )
|
|
|
+ pos = cpos;
|
|
|
+ if( horizontalScrollBar && tm->text && tm->renderer )
|
|
|
+ {
|
|
|
+ if( hatStyleNicht( Style::Mehrzeilig ) )
|
|
|
+ tm->text->remove( '\n' );
|
|
|
+ int br = gr.x;
|
|
|
+ if( hatStyle( Style::Rahmen ) && rahmen )
|
|
|
+ br -= rahmen->getRBreite() * 2;
|
|
|
+ if( hatStyle( Style::VScroll ) && vertikalScrollBar )
|
|
|
+ br -= 15;
|
|
|
+ int maxBr = 0;
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ int lineBr = 0;
|
|
|
+ char buff[] = { 0,0 };
|
|
|
+ int cbr = 0;
|
|
|
+ for( int i = 0; i < len; i++ )
|
|
|
+ {
|
|
|
+ buff[ 0 ] = text[ i ];
|
|
|
+ if( text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ maxBr = maxBr >= lineBr ? maxBr : lineBr;
|
|
|
+ lineBr = 0;
|
|
|
+ tm->nextStyle();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ TextRenderer *r = tm->zCurrentRenderer();
|
|
|
+ if( r )
|
|
|
+ {
|
|
|
+ lineBr += r->getTextBreite( buff );
|
|
|
+ if( i <= pos )
|
|
|
+ cbr = lineBr;
|
|
|
+ }
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ horizontalScrollBar->update( maxBr, br );
|
|
|
+ if( cbr > horizontalScrollBar->getScroll() + horizontalScrollBar->getScrollData()->anzeige )
|
|
|
+ horizontalScrollBar->scroll( cbr - br );
|
|
|
+ if( cbr < horizontalScrollBar->getScroll() )
|
|
|
+ horizontalScrollBar->scroll( cbr );
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
bool TextFeld::tick( double tickval ) // tick
|
|
|
{
|
|
|
- if( hatStyle( Style::Fokus ) )
|
|
|
- {
|
|
|
- if( tickVal < 0.5 && tickVal + tickval >= 0.5 )
|
|
|
- rend = 1;
|
|
|
- if( tickVal >= 0.5 && tickVal + tickval >= 1 )
|
|
|
- rend = 1;
|
|
|
- tickVal += tickval;
|
|
|
- if( tickVal >= 1 )
|
|
|
- tickVal -= 1;
|
|
|
- }
|
|
|
- return ZeichnungHintergrund::tick( tickval );
|
|
|
+ if( hatStyle( Style::Fokus ) )
|
|
|
+ {
|
|
|
+ if( tickVal < 0.5 && tickVal + tickval >= 0.5 )
|
|
|
+ rend = 1;
|
|
|
+ if( tickVal >= 0.5 && tickVal + tickval >= 1 )
|
|
|
+ rend = 1;
|
|
|
+ tickVal += tickval;
|
|
|
+ if( tickVal >= 1 )
|
|
|
+ tickVal -= 1;
|
|
|
+ }
|
|
|
+ return ZeichnungHintergrund::tick( tickval );
|
|
|
}
|
|
|
|
|
|
void TextFeld::doMausEreignis( MausEreignis &me ) // Maus Ereignis
|
|
|
{
|
|
|
- bool nmakc = !me.verarbeitet;
|
|
|
- if( hatStyleNicht( Style::Erlaubt ) || hatStyleNicht( Style::Sichtbar ) )
|
|
|
- {
|
|
|
- if( toolTip )
|
|
|
- toolTip->setMausIn( 0 );
|
|
|
- me.mx -= pos.x, me.my -= pos.y;
|
|
|
- int rbr = 0;
|
|
|
- if( rahmen )
|
|
|
- rbr = rahmen->getRBreite();
|
|
|
- if( ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ||
|
|
|
- ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ) &&
|
|
|
- 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.mx += pos.x, me.my += pos.y;
|
|
|
- mausKlick = 0;
|
|
|
- return;
|
|
|
- }
|
|
|
- bool removeFokus = 0;
|
|
|
- if( me.verarbeitet || !( me.mx >= pos.x && me.mx <= pos.x + gr.x && me.my >= pos.y && me.my <= pos.y + gr.y ) )
|
|
|
- {
|
|
|
- if( mausIn )
|
|
|
- {
|
|
|
- mausIn = 0;
|
|
|
- if( toolTip )
|
|
|
- toolTip->setMausIn( 0 );
|
|
|
- MausEreignis me2;
|
|
|
- me2.id = ME_Leaves;
|
|
|
- me2.mx = me.mx;
|
|
|
- me2.my = me.my;
|
|
|
- me2.verarbeitet = 0;
|
|
|
- doMausEreignis( me2 );
|
|
|
- return;
|
|
|
- }
|
|
|
- removeFokus = 1;
|
|
|
- }
|
|
|
- if( !( me.mx >= pos.x && me.mx <= pos.x + gr.x && me.my >= pos.y && me.my <= pos.y + gr.y ) && me.id != ME_Leaves )
|
|
|
- {
|
|
|
- if( removeFokus && me.id == ME_RLinks )
|
|
|
- {
|
|
|
- me.mx -= pos.x, me.my -= pos.y;
|
|
|
- if( hatStyle( Style::Fokus ) && mak && ( me.verarbeitet || mak( makParam, this, me ) ) )
|
|
|
- removeStyle( Style::Fokus );
|
|
|
- if( nmakc && me.verarbeitet && nMak )
|
|
|
- me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
- me.mx += pos.x, me.my += pos.y;
|
|
|
- }
|
|
|
- if( toolTip )
|
|
|
- toolTip->setMausIn( 0 );
|
|
|
- return;
|
|
|
- }
|
|
|
- if( !mausIn && me.id != ME_Leaves )
|
|
|
- {
|
|
|
- mausIn = 1;
|
|
|
- if( toolTip )
|
|
|
- toolTip->setMausIn( 1 );
|
|
|
- MausEreignis me2;
|
|
|
- me2.id = ME_Betritt;
|
|
|
- me2.mx = me.mx;
|
|
|
- me2.my = me.my;
|
|
|
- me2.verarbeitet = 0;
|
|
|
- doMausEreignis( me2 );
|
|
|
- }
|
|
|
- me.mx -= pos.x, me.my -= pos.y;
|
|
|
- if( mak && ( me.verarbeitet || mak( makParam, this, me ) ) )
|
|
|
- {
|
|
|
- if( removeFokus && me.id == ME_RLinks )
|
|
|
- removeStyle( Style::Fokus );
|
|
|
- if( !me.verarbeitet )
|
|
|
- {
|
|
|
- if( hatStyleNicht( Style::Fokus ) )
|
|
|
- {
|
|
|
- mausKlick = 0;
|
|
|
- if( me.id == Framework::ME_PLinks )
|
|
|
- addStyle( Style::Fokus );
|
|
|
- }
|
|
|
- int rbr = 0;
|
|
|
- if( rahmen )
|
|
|
- rbr = rahmen->getRBreite();
|
|
|
- if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
- {
|
|
|
- if( vertikalScrollBar->doMausMessage( gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me ) )
|
|
|
- {
|
|
|
- if( nmakc && me.verarbeitet && nMak )
|
|
|
- me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
- me.mx += pos.x, me.my += pos.y;
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
- {
|
|
|
- if( horizontalScrollBar->doMausMessage( rbr, gr.y - rbr - 15, gr.x - rbr * 2 - ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? 15 : 0 ), 15, me ) )
|
|
|
- {
|
|
|
- if( nmakc && me.verarbeitet && nMak )
|
|
|
- me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
- me.mx += pos.x, me.my += pos.y;
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if( me.mx < gr.x - rbr - 15 )
|
|
|
- {
|
|
|
- if( textRd )
|
|
|
- {
|
|
|
- textRd->setSchriftSize( schriftSize );
|
|
|
- bool shift = TastenStand[ T_Shift ];
|
|
|
- if( me.id == Framework::ME_PLinks )
|
|
|
- {
|
|
|
- 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;
|
|
|
- int yyy = me.my - rbr + scrollHi;
|
|
|
- int scrollBreite = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) * 15;
|
|
|
- if( hatStyle( Style::HCenter ) )
|
|
|
- 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 = textRd->textPos( text->getText(), xxx, yyy );
|
|
|
- if( pos != -1 )
|
|
|
- {
|
|
|
- if( shift )
|
|
|
- begf = pos;
|
|
|
- else
|
|
|
- {
|
|
|
- cpos = pos;
|
|
|
- begf = pos;
|
|
|
- }
|
|
|
- rend = 1;
|
|
|
- if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll( begf );
|
|
|
- if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll( begf );
|
|
|
- }
|
|
|
- mausKlick = 1;
|
|
|
- }
|
|
|
- if( me.id == ME_Bewegung && mausKlick )
|
|
|
- {
|
|
|
- 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;
|
|
|
- int yyy = me.my - rbr + scrollHi;
|
|
|
- int scrollBreite = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) * 15;
|
|
|
- int scrollHeight = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) * 15;
|
|
|
- if( hatStyle( Style::HCenter ) )
|
|
|
- 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 = textRd->textPos( text->getText(), xxx, yyy );
|
|
|
- if( pos != -1 )
|
|
|
- {
|
|
|
- if( begf != pos )
|
|
|
- rend = 1;
|
|
|
- begf = pos;
|
|
|
- if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll( begf );
|
|
|
- if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll( begf );
|
|
|
- }
|
|
|
- }
|
|
|
- if( me.id == ME_RLinks )
|
|
|
- {
|
|
|
- if( !shift )
|
|
|
- {
|
|
|
- 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;
|
|
|
- int yyy = me.my - rbr + scrollHi;
|
|
|
- int scrollBreite = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) * 15;
|
|
|
- int scrollHeight = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) * 15;
|
|
|
- if( hatStyle( Style::HCenter ) )
|
|
|
- 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 = textRd->textPos( text->getText(), xxx, yyy );
|
|
|
- if( pos != -1 )
|
|
|
- {
|
|
|
- begf = pos;
|
|
|
- if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll( begf );
|
|
|
- if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll( begf );
|
|
|
- }
|
|
|
- rend = 1;
|
|
|
- }
|
|
|
- mausKlick = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- me.verarbeitet = 1;
|
|
|
- }
|
|
|
- if( nmakc && me.verarbeitet && nMak )
|
|
|
- me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
- me.mx += pos.x, me.my += pos.y;
|
|
|
+ bool nmakc = !me.verarbeitet;
|
|
|
+ if( hatStyleNicht( Style::Erlaubt ) || hatStyleNicht( Style::Sichtbar ) )
|
|
|
+ {
|
|
|
+ if( toolTip )
|
|
|
+ toolTip->setMausIn( 0 );
|
|
|
+ me.mx -= pos.x, me.my -= pos.y;
|
|
|
+ int rbr = 0;
|
|
|
+ if( rahmen )
|
|
|
+ rbr = rahmen->getRBreite();
|
|
|
+ if( ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ||
|
|
|
+ ( horizontalScrollBar && hatStyle( Style::HScroll ) ) ) &&
|
|
|
+ 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.mx += pos.x, me.my += pos.y;
|
|
|
+ mausKlick = 0;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ bool removeFokus = 0;
|
|
|
+ if( me.verarbeitet || !( me.mx >= pos.x && me.mx <= pos.x + gr.x && me.my >= pos.y && me.my <= pos.y + gr.y ) )
|
|
|
+ {
|
|
|
+ if( mausIn )
|
|
|
+ {
|
|
|
+ mausIn = 0;
|
|
|
+ if( toolTip )
|
|
|
+ toolTip->setMausIn( 0 );
|
|
|
+ MausEreignis me2;
|
|
|
+ me2.id = ME_Leaves;
|
|
|
+ me2.mx = me.mx;
|
|
|
+ me2.my = me.my;
|
|
|
+ me2.verarbeitet = 0;
|
|
|
+ doMausEreignis( me2 );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ removeFokus = 1;
|
|
|
+ }
|
|
|
+ if( !( me.mx >= pos.x && me.mx <= pos.x + gr.x && me.my >= pos.y && me.my <= pos.y + gr.y ) && me.id != ME_Leaves )
|
|
|
+ {
|
|
|
+ if( removeFokus && me.id == ME_RLinks )
|
|
|
+ {
|
|
|
+ me.mx -= pos.x, me.my -= pos.y;
|
|
|
+ if( hatStyle( Style::Fokus ) && mak && ( me.verarbeitet || mak( makParam, this, me ) ) )
|
|
|
+ removeStyle( Style::Fokus );
|
|
|
+ if( nmakc && me.verarbeitet && nMak )
|
|
|
+ me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
+ me.mx += pos.x, me.my += pos.y;
|
|
|
+ }
|
|
|
+ if( toolTip )
|
|
|
+ toolTip->setMausIn( 0 );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if( !mausIn && me.id != ME_Leaves )
|
|
|
+ {
|
|
|
+ mausIn = 1;
|
|
|
+ if( toolTip )
|
|
|
+ toolTip->setMausIn( 1 );
|
|
|
+ MausEreignis me2;
|
|
|
+ me2.id = ME_Betritt;
|
|
|
+ me2.mx = me.mx;
|
|
|
+ me2.my = me.my;
|
|
|
+ me2.verarbeitet = 0;
|
|
|
+ doMausEreignis( me2 );
|
|
|
+ }
|
|
|
+ me.mx -= pos.x, me.my -= pos.y;
|
|
|
+ if( mak && ( me.verarbeitet || mak( makParam, this, me ) ) )
|
|
|
+ {
|
|
|
+ if( removeFokus && me.id == ME_RLinks )
|
|
|
+ removeStyle( Style::Fokus );
|
|
|
+ if( !me.verarbeitet )
|
|
|
+ {
|
|
|
+ if( hatStyleNicht( Style::Fokus ) )
|
|
|
+ {
|
|
|
+ mausKlick = 0;
|
|
|
+ if( me.id == Framework::ME_PLinks )
|
|
|
+ addStyle( Style::Fokus );
|
|
|
+ }
|
|
|
+ int rbr = 0;
|
|
|
+ if( rahmen )
|
|
|
+ rbr = rahmen->getRBreite();
|
|
|
+ if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
+ {
|
|
|
+ if( vertikalScrollBar->doMausMessage( gr.x - rbr - 15, rbr, 15, gr.y - rbr * 2, me ) )
|
|
|
+ {
|
|
|
+ if( nmakc && me.verarbeitet && nMak )
|
|
|
+ me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
+ me.mx += pos.x, me.my += pos.y;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
+ {
|
|
|
+ if( horizontalScrollBar->doMausMessage( rbr, gr.y - rbr - 15, gr.x - rbr * 2 - ( ( vertikalScrollBar && hatStyle( Style::VScroll ) ) ? 15 : 0 ), 15, me ) )
|
|
|
+ {
|
|
|
+ if( nmakc && me.verarbeitet && nMak )
|
|
|
+ me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
+ me.mx += pos.x, me.my += pos.y;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bool shift = TastenStand[ T_Shift ];
|
|
|
+ bool strg = TastenStand[ T_Strg ];
|
|
|
+ int tbr = getTextWidth();
|
|
|
+ int thi = getTextHeight();
|
|
|
+ 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 );
|
|
|
+ int scrollBreite = ( vertikalScrollBar && hatStyle( Style::VScroll ) ) * 15;
|
|
|
+ int scrollHeight = ( horizontalScrollBar && hatStyle( Style::HScroll ) ) * 15;
|
|
|
+ if( hatStyle( Style::HCenter ) )
|
|
|
+ xxx -= ( ( ( gr.x - scrollBreite ) / 2 ) - tbr / 2 ) - rbr;
|
|
|
+ if( hatStyle( Style::VCenter ) && hatStyleNicht( Style::VScroll ) )
|
|
|
+ yyy -= ( ( ( gr.y - scrollHeight ) / 2 ) - thi / 2 ) - rbr;
|
|
|
+ if( mausChar >= 0 )
|
|
|
+ {
|
|
|
+ TextStyle s = tm->getTextStyle( mausChar );
|
|
|
+ if( s.onClick )
|
|
|
+ s.onClick( 0, this, me );
|
|
|
+ }
|
|
|
+ if( me.mx < gr.x - rbr - 15 )
|
|
|
+ {
|
|
|
+ if( tm->renderer )
|
|
|
+ {
|
|
|
+ int ncpos = getCurserPosAt( xxx, yyy );
|
|
|
+ if( me.id == Framework::ME_PLinks )
|
|
|
+ {
|
|
|
+ if( ncpos != -1 )
|
|
|
+ {
|
|
|
+ if( shift && cpos != ncpos )
|
|
|
+ addAuswahl( MIN( cpos, ncpos ), MAX( cpos, ncpos ) );
|
|
|
+ else if( !shift && !mausKlick && !strg )
|
|
|
+ deselectAuswahl();
|
|
|
+ cpos = ncpos;
|
|
|
+ rend = 1;
|
|
|
+ if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll();
|
|
|
+ if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll();
|
|
|
+ }
|
|
|
+ mausKlick = 1;
|
|
|
+ }
|
|
|
+ if( me.id == ME_Bewegung && mausKlick )
|
|
|
+ {
|
|
|
+ if( ncpos != -1 )
|
|
|
+ {
|
|
|
+ rend = 1;
|
|
|
+ if( cpos != ncpos )
|
|
|
+ invertAuswahl( MIN( cpos, ncpos ), MAX( cpos, ncpos ) );
|
|
|
+ cpos = ncpos;
|
|
|
+ if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll( cpos );
|
|
|
+ if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll( cpos );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( me.id == ME_RLinks )
|
|
|
+ {
|
|
|
+ if( ncpos != -1 )
|
|
|
+ {
|
|
|
+ rend = 1;
|
|
|
+ if( cpos != ncpos )
|
|
|
+ invertAuswahl( MIN( cpos, ncpos ), MAX( cpos, ncpos ) );
|
|
|
+ cpos = ncpos;
|
|
|
+ if( vertikalScrollBar && hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll( cpos );
|
|
|
+ if( horizontalScrollBar && hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll( cpos );
|
|
|
+ }
|
|
|
+ mausKlick = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.verarbeitet = 1;
|
|
|
+ }
|
|
|
+ if( nmakc && me.verarbeitet && nMak )
|
|
|
+ me.verarbeitet = nMak( nmakParam, this, me );
|
|
|
+ me.mx += pos.x, me.my += pos.y;
|
|
|
}
|
|
|
|
|
|
void TextFeld::doTastaturEreignis( TastaturEreignis &te )
|
|
|
{
|
|
|
- bool ntakc = !te.verarbeitet;
|
|
|
- if( te.verarbeitet || hatStyleNicht( Style::Fokus ) )
|
|
|
- return;
|
|
|
- if( !tak )
|
|
|
- return;
|
|
|
- ++ref;
|
|
|
- if( tak( takParam, this, te ) )
|
|
|
- {
|
|
|
- if( hatStyleNicht( Style::Erlaubt ) )
|
|
|
- {
|
|
|
- --ref;
|
|
|
- if( !ref )
|
|
|
- delete this;
|
|
|
- return;
|
|
|
- }
|
|
|
- if( te.id == TE_Press )
|
|
|
- {
|
|
|
- bool shift = TastenStand[ T_Shift ];
|
|
|
- bool strg = TastenStand[ T_Strg ];
|
|
|
- switch( te.taste )
|
|
|
- {
|
|
|
- case T_Entf:
|
|
|
- if( cpos != begf )
|
|
|
- text->remove( cpos, begf );
|
|
|
- else
|
|
|
- text->remove( cpos, cpos + 1 );
|
|
|
- begf = cpos;
|
|
|
- rend = 1;
|
|
|
- break;
|
|
|
- case T_BackSpace:
|
|
|
- if( cpos != begf )
|
|
|
- {
|
|
|
- text->remove( cpos, begf );
|
|
|
- if( cpos > begf )
|
|
|
- cpos -= cpos - begf;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- text->remove( cpos - 1, cpos );
|
|
|
- --cpos;
|
|
|
- }
|
|
|
- begf = cpos;
|
|
|
- rend = 1;
|
|
|
- break;
|
|
|
- case T_Enter:
|
|
|
- if( cpos != begf )
|
|
|
- {
|
|
|
- text->remove( begf, cpos );
|
|
|
- if( cpos > begf )
|
|
|
- cpos -= cpos - begf;
|
|
|
- }
|
|
|
- text->insert( cpos, '\n' );
|
|
|
- ++cpos;
|
|
|
- begf = cpos;
|
|
|
- rend = 1;
|
|
|
- break;
|
|
|
- case T_Links:
|
|
|
- if( shift )
|
|
|
- {
|
|
|
- if( strg )
|
|
|
- begf = text->getLKick( begf );
|
|
|
- else
|
|
|
- --begf;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if( strg )
|
|
|
- cpos = text->getLKick( cpos );
|
|
|
- else
|
|
|
- --cpos;
|
|
|
- begf = cpos;
|
|
|
- }
|
|
|
- rend = 1;
|
|
|
- break;
|
|
|
- case T_Oben:
|
|
|
- if( shift )
|
|
|
- {
|
|
|
- begf = text->getOKick( begf );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- cpos = text->getOKick( cpos );
|
|
|
- begf = cpos;
|
|
|
- }
|
|
|
- rend = 1;
|
|
|
- break;
|
|
|
- case T_Rechts:
|
|
|
- if( shift )
|
|
|
- {
|
|
|
- if( strg )
|
|
|
- begf = text->getRKick( begf );
|
|
|
- else
|
|
|
- ++begf;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if( strg )
|
|
|
- cpos = text->getRKick( cpos );
|
|
|
- else
|
|
|
- ++cpos;
|
|
|
- begf = cpos;
|
|
|
- }
|
|
|
- rend = 1;
|
|
|
- break;
|
|
|
- case T_Unten:
|
|
|
- if( shift )
|
|
|
- {
|
|
|
- begf = text->getUKick( begf );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- cpos = text->getUKick( cpos );
|
|
|
- begf = cpos;
|
|
|
- }
|
|
|
- rend = 1;
|
|
|
- break;
|
|
|
- default:
|
|
|
- if( strg && te.id == TE_Press )
|
|
|
- {
|
|
|
- if( te.taste == 'c' || te.taste == 'C' )
|
|
|
- {
|
|
|
- if( begf != cpos )
|
|
|
- {
|
|
|
- int len = begf - cpos;
|
|
|
- if( len < 0 )
|
|
|
- len = -len;
|
|
|
- char *txt = new char[ len + 1 ];
|
|
|
- txt[ len ] = 0;
|
|
|
- int beg = begf < cpos ? begf : cpos;
|
|
|
- for( int i = beg; i < beg + len; ++i )
|
|
|
- txt[ i - beg ] = text->getText()[ i ];
|
|
|
- TextKopieren( txt );
|
|
|
- delete[] txt;
|
|
|
- }
|
|
|
- else
|
|
|
- TextKopieren( text->getText() );
|
|
|
- }
|
|
|
- if( te.taste == 'v' || te.taste == 'V' )
|
|
|
- {
|
|
|
- if( begf != cpos )
|
|
|
- {
|
|
|
- text->remove( begf, cpos );
|
|
|
- if( cpos > begf )
|
|
|
- cpos = begf;
|
|
|
- }
|
|
|
- char *txt = TextInsert();
|
|
|
- text->insert( cpos, txt );
|
|
|
- cpos += textLength( txt );
|
|
|
- begf = cpos;
|
|
|
- rend = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- if( istSchreibbar( te.taste ) )
|
|
|
- {
|
|
|
- if( begf != cpos )
|
|
|
- {
|
|
|
- text->remove( begf, cpos );
|
|
|
- if( cpos > begf )
|
|
|
- cpos = begf;
|
|
|
- }
|
|
|
- text->insert( cpos, (char)te.taste );
|
|
|
- ++cpos;
|
|
|
- begf = cpos;
|
|
|
- rend = 1;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if( cpos < 0 )
|
|
|
- cpos = 0;
|
|
|
- if( cpos > text->getLength() )
|
|
|
- cpos = text->getLength();
|
|
|
- if( begf < 0 )
|
|
|
- begf = 0;
|
|
|
- if( begf > text->getLength() )
|
|
|
- begf = text->getLength();
|
|
|
- if( hatStyle( Style::VScroll ) )
|
|
|
- updateVScroll( begf );
|
|
|
- if( hatStyle( Style::HScroll ) )
|
|
|
- updateHScroll( begf );
|
|
|
- te.verarbeitet = 1;
|
|
|
- }
|
|
|
- --ref;
|
|
|
- if( ntakc && te.verarbeitet && nTak )
|
|
|
- te.verarbeitet = nTak( ntakParam, this, te );
|
|
|
- if( !ref )
|
|
|
- delete this;
|
|
|
+ bool ntakc = !te.verarbeitet;
|
|
|
+ if( te.verarbeitet || hatStyleNicht( Style::Fokus ) )
|
|
|
+ return;
|
|
|
+ if( !tak )
|
|
|
+ return;
|
|
|
+ ++ref;
|
|
|
+ if( tak( takParam, this, te ) )
|
|
|
+ {
|
|
|
+ if( hatStyleNicht( Style::Erlaubt ) )
|
|
|
+ {
|
|
|
+ --ref;
|
|
|
+ if( !ref )
|
|
|
+ delete this;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if( te.id == TE_Press )
|
|
|
+ {
|
|
|
+ bool shift = TastenStand[ T_Shift ];
|
|
|
+ bool strg = TastenStand[ T_Strg ];
|
|
|
+ switch( te.taste )
|
|
|
+ {
|
|
|
+ case T_Entf:
|
|
|
+ if( !tm->getTextStyle( cpos ).selected )
|
|
|
+ tm->removeText( cpos, cpos + 1 );
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cpos = tm->getTextStyle( cpos ).beginIndex;
|
|
|
+ while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
|
|
|
+ cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
|
|
|
+ }
|
|
|
+ replaceAuswahl( "" );
|
|
|
+ deselectAuswahl();
|
|
|
+ rend = 1;
|
|
|
+ break;
|
|
|
+ case T_BackSpace:
|
|
|
+ if( !tm->getTextStyle( cpos ).selected )
|
|
|
+ {
|
|
|
+ tm->removeText( cpos - 1, cpos );
|
|
|
+ cpos--;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cpos = tm->getTextStyle( cpos ).beginIndex;
|
|
|
+ while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
|
|
|
+ cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
|
|
|
+ }
|
|
|
+ replaceAuswahl( "" );
|
|
|
+ deselectAuswahl();
|
|
|
+ rend = 1;
|
|
|
+ break;
|
|
|
+ case T_Enter:
|
|
|
+ if( !tm->getTextStyle( cpos ).selected )
|
|
|
+ tm->insertText( cpos, "\n" );
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cpos = tm->getTextStyle( cpos ).beginIndex;
|
|
|
+ while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
|
|
|
+ cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
|
|
|
+ }
|
|
|
+ replaceAuswahl( "\n" );
|
|
|
+ ++cpos;
|
|
|
+ rend = 1;
|
|
|
+ break;
|
|
|
+ case T_Links:
|
|
|
+ if( shift )
|
|
|
+ {
|
|
|
+ if( strg )
|
|
|
+ {
|
|
|
+ int tmp = tm->text->getLKick( cpos );
|
|
|
+ invertAuswahl( tmp, cpos );
|
|
|
+ cpos = tmp;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ invertAuswahl( cpos - 1, cpos );
|
|
|
+ --cpos;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if( strg )
|
|
|
+ cpos = tm->text->getLKick( cpos );
|
|
|
+ else
|
|
|
+ --cpos;
|
|
|
+ deselectAuswahl();
|
|
|
+ }
|
|
|
+ rend = 1;
|
|
|
+ break;
|
|
|
+ case T_Oben:
|
|
|
+ {
|
|
|
+ int tmp = tm->text->getOKick( cpos );
|
|
|
+ invertAuswahl( tmp, cpos );
|
|
|
+ cpos = tmp;
|
|
|
+ if( !shift )
|
|
|
+ deselectAuswahl();
|
|
|
+ rend = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case T_Rechts:
|
|
|
+ if( shift )
|
|
|
+ {
|
|
|
+ if( strg )
|
|
|
+ {
|
|
|
+ int tmp = tm->text->getRKick( cpos );
|
|
|
+ invertAuswahl( cpos, tmp );
|
|
|
+ cpos = tmp;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ invertAuswahl( cpos, cpos + 1 );
|
|
|
+ ++cpos;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if( strg )
|
|
|
+ cpos = tm->text->getRKick( cpos );
|
|
|
+ else
|
|
|
+ ++cpos;
|
|
|
+ deselectAuswahl();
|
|
|
+ }
|
|
|
+ rend = 1;
|
|
|
+ break;
|
|
|
+ case T_Unten:
|
|
|
+ {
|
|
|
+ int tmp = tm->text->getUKick( cpos );
|
|
|
+ invertAuswahl( cpos, tmp );
|
|
|
+ cpos = tmp;
|
|
|
+ if( !shift )
|
|
|
+ deselectAuswahl();
|
|
|
+ rend = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ if( strg && te.id == TE_Press )
|
|
|
+ {
|
|
|
+ if( te.taste == 'c' || te.taste == 'C' )
|
|
|
+ {
|
|
|
+ int sa = tm->textStyle.getEintragAnzahl();
|
|
|
+ int length = 0;
|
|
|
+ for( int i = 0; i < sa; i++ )
|
|
|
+ {
|
|
|
+ TextStyle s = tm->textStyle.get( i );
|
|
|
+ if( s.selected )
|
|
|
+ {
|
|
|
+ int max = tm->text->getLength();
|
|
|
+ if( i < sa - 1 )
|
|
|
+ max = tm->textStyle.get( i + 1 ).beginIndex;
|
|
|
+ length += max - s.beginIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( length )
|
|
|
+ {
|
|
|
+ char *txt = new char[ length + 1 ];
|
|
|
+ txt[ length ] = 0;
|
|
|
+ int index = 0;
|
|
|
+ for( int i = 0; i < sa; i++ )
|
|
|
+ {
|
|
|
+ TextStyle s = tm->textStyle.get( i );
|
|
|
+ if( s.selected )
|
|
|
+ {
|
|
|
+ int max = tm->text->getLength();
|
|
|
+ if( i < sa - 1 )
|
|
|
+ max = tm->textStyle.get( i + 1 ).beginIndex;
|
|
|
+ memcpy( txt + index, tm->text->getText() + s.beginIndex, max - s.beginIndex );
|
|
|
+ index += max - s.beginIndex;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TextKopieren( txt );
|
|
|
+ delete[] txt;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ TextKopieren( tm->text->getText() );
|
|
|
+ }
|
|
|
+ if( te.taste == 'v' || te.taste == 'V' )
|
|
|
+ {
|
|
|
+ char *txt = TextInsert();
|
|
|
+ if( !tm->getTextStyle( cpos ).selected )
|
|
|
+ tm->insertText( cpos, txt );
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cpos = tm->getTextStyle( cpos ).beginIndex;
|
|
|
+ while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
|
|
|
+ cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
|
|
|
+ }
|
|
|
+ replaceAuswahl( txt );
|
|
|
+ cpos += textLength( txt );
|
|
|
+ rend = 1;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if( istSchreibbar( te.taste ) )
|
|
|
+ {
|
|
|
+ char buff[] = { (char)te.taste, 0 };
|
|
|
+ if( !tm->getTextStyle( cpos ).selected )
|
|
|
+ tm->insertText( cpos, buff );
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cpos = tm->getTextStyle( cpos ).beginIndex;
|
|
|
+ while( cpos > 0 && tm->getTextStyle( cpos - 1 ).selected )
|
|
|
+ cpos = tm->getTextStyle( cpos - 1 ).beginIndex;
|
|
|
+ }
|
|
|
+ replaceAuswahl( buff );
|
|
|
+ ++cpos;
|
|
|
+ rend = 1;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( cpos < 0 )
|
|
|
+ cpos = 0;
|
|
|
+ if( cpos > tm->text->getLength() )
|
|
|
+ cpos = tm->text->getLength();
|
|
|
+ if( hatStyle( Style::VScroll ) )
|
|
|
+ updateVScroll( cpos );
|
|
|
+ if( hatStyle( Style::HScroll ) )
|
|
|
+ updateHScroll( cpos );
|
|
|
+ te.verarbeitet = 1;
|
|
|
+ }
|
|
|
+ --ref;
|
|
|
+ if( ntakc && te.verarbeitet && nTak )
|
|
|
+ te.verarbeitet = nTak( ntakParam, this, te );
|
|
|
+ if( !ref )
|
|
|
+ delete this;
|
|
|
}
|
|
|
|
|
|
void TextFeld::render( Bild &zRObj ) // zeichenet nach zRObj
|
|
|
{
|
|
|
- if( hatStyleNicht( Style::Sichtbar ) )
|
|
|
- return;
|
|
|
- ZeichnungHintergrund::render( zRObj );
|
|
|
- if( !text || !textRd )
|
|
|
- return;
|
|
|
- lockZeichnung();
|
|
|
- if( !zRObj.setDrawOptions( innenPosition, innenSize ) )
|
|
|
- {
|
|
|
- unlockZeichnung();
|
|
|
- return;
|
|
|
- }
|
|
|
- if( hatStyleNicht( Style::Mehrzeilig ) )
|
|
|
- text->remove( '\n' );
|
|
|
- if( hatStyleNicht( Style::Mehrfarbig ) )
|
|
|
- {
|
|
|
- while( text->hat( '\r' ) )
|
|
|
- text->remove( text->positionVon( '\r' ), text->positionVon( '\r' ) + 11 );
|
|
|
- }
|
|
|
- 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;
|
|
|
- int height = innenSize.y;
|
|
|
- bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
|
|
|
- bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
|
|
|
- if( vs )
|
|
|
- yyy -= vertikalScrollBar->getScroll();
|
|
|
- if( hs )
|
|
|
- xxx -= horizontalScrollBar->getScroll();
|
|
|
- if( hatStyle( Style::HCenter ) && !hs )
|
|
|
- xxx = ( breite / 2 ) - tbr / 2;
|
|
|
- if( hatStyle( Style::VCenter ) && !vs )
|
|
|
- yyy = ( height / 2 ) - thi / 2;
|
|
|
- if( hatStyle( Style::Fokus ) && hatStyle( Style::Erlaubt ) )
|
|
|
- {
|
|
|
- if( istSchreibbar( showChar ) )
|
|
|
- {
|
|
|
- Text rt;
|
|
|
- int len = text->getLength() - text->anzahlVon( '\n' ) - text->anzahlVon( '\r' ) * 11;
|
|
|
- rt.fillText( showChar, len );
|
|
|
- if( tickVal <= 0.5 )
|
|
|
- textRd->renderText( xxx, yyy, rt, zRObj, sF, cpos, 0xFFFF5555, begf, 0xFF0000FF );
|
|
|
- else
|
|
|
- textRd->renderText( xxx, yyy, rt, zRObj, sF, cpos, 0x00000000, begf, 0xFF0000FF );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if( tickVal <= 0.5 )
|
|
|
- textRd->renderText( xxx, yyy, text->getText(), zRObj, sF, cpos, 0xFFFF5555, begf, 0xFF0000FF );
|
|
|
- else
|
|
|
- textRd->renderText( xxx, yyy, text->getText(), zRObj, sF, cpos, 0x00000000, begf, 0xFF0000FF );
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if( istSchreibbar( showChar ) )
|
|
|
- {
|
|
|
- Text rt;
|
|
|
- int len = text->getLength() - text->anzahlVon( '\n' ) - text->anzahlVon( '\r' ) * 11;
|
|
|
- rt.fillText( showChar, len );
|
|
|
- textRd->renderText( xxx, yyy, rt, zRObj, sF );
|
|
|
- }
|
|
|
- else
|
|
|
- textRd->renderText( xxx, yyy, text->getText(), zRObj, sF );
|
|
|
- }
|
|
|
- zRObj.releaseDrawOptions();
|
|
|
- unlockZeichnung();
|
|
|
+ if( hatStyleNicht( Style::Sichtbar ) )
|
|
|
+ return;
|
|
|
+ ZeichnungHintergrund::render( zRObj );
|
|
|
+ if( !tm->text || !tm->renderer )
|
|
|
+ return;
|
|
|
+ lockZeichnung();
|
|
|
+ if( !zRObj.setDrawOptions( innenPosition, innenSize ) )
|
|
|
+ {
|
|
|
+ unlockZeichnung();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if( hatStyleNicht( Style::Mehrzeilig ) )
|
|
|
+ tm->text->remove( '\n' );
|
|
|
+ int tbr = getTextWidth();
|
|
|
+ int thi = getTextHeight();
|
|
|
+ int xxx = 0;
|
|
|
+ int yyy = 0;
|
|
|
+ int breite = innenSize.x;
|
|
|
+ int height = innenSize.y;
|
|
|
+ bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
|
|
|
+ bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
|
|
|
+ if( vs )
|
|
|
+ yyy -= vertikalScrollBar->getScroll();
|
|
|
+ if( hs )
|
|
|
+ xxx -= horizontalScrollBar->getScroll();
|
|
|
+ if( hatStyle( Style::HCenter ) && !hs )
|
|
|
+ xxx = ( breite / 2 ) - tbr / 2;
|
|
|
+ if( hatStyle( Style::VCenter ) && !vs )
|
|
|
+ yyy = ( height / 2 ) - thi / 2;
|
|
|
+ int x = xxx;
|
|
|
+ int y = yyy;
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ lockZeichnung();
|
|
|
+ tm->resetIteration();
|
|
|
+ TextStyle &style = tm->currentStyle();
|
|
|
+ int maxLH = 0;
|
|
|
+ for( int i = 0; i <= len; i++ )
|
|
|
+ {
|
|
|
+ int oldX = x;
|
|
|
+ if( i < len )
|
|
|
+ tm->zCurrentRenderer()->renderChar( x, y, istSchreibbar( showChar ) ? showChar : text[ i ], zRObj, style.selected ? style.selectedColor : style.fontColor, style.underlined, style.selected, style.selectedBackcroundColor );
|
|
|
+ if( i == cpos && tickVal <= 0.5 && hatStyle( Style::Fokus ) && hatStyle( Style::Erlaubt ) )
|
|
|
+ zRObj.drawLinieV( oldX, y, tm->zCurrentRenderer()->getZeilenHeight(), 0xFFFF5555 );
|
|
|
+ int tmp = tm->zCurrentRenderer()->getZeilenHeight() + tm->zCurrentRenderer()->getZeilenAbstand();
|
|
|
+ maxLH = tmp > maxLH ? tmp : maxLH;
|
|
|
+ if( i < len && text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ x = xxx;
|
|
|
+ y += maxLH;
|
|
|
+ }
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ unlockZeichnung();
|
|
|
+ zRObj.releaseDrawOptions();
|
|
|
+ unlockZeichnung();
|
|
|
}
|
|
|
|
|
|
// Konstant
|
|
|
Text *TextFeld::getText() const // gibt vom Text zurück
|
|
|
{
|
|
|
- if( !text )
|
|
|
- return 0;
|
|
|
- return text->getThis();
|
|
|
+ if( !tm->text )
|
|
|
+ return 0;
|
|
|
+ return tm->text->getThis();
|
|
|
}
|
|
|
|
|
|
Text *TextFeld::zText() const // gibt den Text zurück
|
|
|
{
|
|
|
- return text;
|
|
|
+ return tm->text;
|
|
|
}
|
|
|
|
|
|
Schrift *TextFeld::getSchrift() const// gint getThis der Schrift Zurück
|
|
|
{
|
|
|
- if( !textRd )
|
|
|
- return 0;
|
|
|
- return textRd->getSchrift();
|
|
|
+ tm->resetIteration();
|
|
|
+ return tm->zCurrentRenderer()->getSchrift();
|
|
|
}
|
|
|
|
|
|
Schrift *TextFeld::zSchrift() const// gibt die Schrift zurück
|
|
|
{
|
|
|
- return textRd ? textRd->zSchrift() : 0;
|
|
|
+ tm->resetIteration();
|
|
|
+ return tm->zCurrentRenderer()->zSchrift();
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt die Schrift zurück.
|
|
|
+// rendererIndex: Der Index des Renderers dessen Schrift zurückgegeben werden soll
|
|
|
+// return: 0, falls die Schrift nicht gesetzt wurde
|
|
|
+Schrift *TextFeld::getSchrift( int rendererIndex ) const
|
|
|
+{
|
|
|
+ if( tm->renderer && tm->renderer->z( rendererIndex ) )
|
|
|
+ return tm->renderer->z( rendererIndex )->getSchrift();
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt die Schrift ohne erhöhten Reference Counter zurük
|
|
|
+// rendererIndex: Der Index des Renderers dessen Schrift zurückgegeben werden soll
|
|
|
+// return: 0, falls die Schrift nicht gesetzt wurde
|
|
|
+Schrift *TextFeld::zSchrift( int rendererIndex ) const
|
|
|
+{
|
|
|
+ if( tm->renderer && tm->renderer->z( rendererIndex ) )
|
|
|
+ return tm->renderer->z( rendererIndex )->zSchrift();
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
TextRenderer *TextFeld::getTextRenderer() const
|
|
|
{
|
|
|
- return textRd ? textRd->getThis() : 0;
|
|
|
+ tm->resetIteration();
|
|
|
+ return tm->zCurrentRenderer()->getThis();
|
|
|
}
|
|
|
|
|
|
TextRenderer *TextFeld::zTextRenderer() const
|
|
|
{
|
|
|
- return textRd;
|
|
|
+ tm->resetIteration();
|
|
|
+ return tm->zCurrentRenderer();
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt den TextRenderer zurück.
|
|
|
+// index: Der Index des Renderers der zurückgegeben werden soll
|
|
|
+// return: 0, falls der TextRenderer nicht gesetzt wurde
|
|
|
+TextRenderer *TextFeld::getTextRenderer( int index ) const
|
|
|
+{
|
|
|
+ if( tm->renderer && tm->renderer->z( index ) )
|
|
|
+ return tm->renderer->get( index );
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt dien TextRenderer ohne erhöhten Reference Counter zurük
|
|
|
+// index: Der Index des Renderers der zurückgegeben werden soll
|
|
|
+// return: 0, falls der TextRenderer nicht gesetzt wurde
|
|
|
+TextRenderer *TextFeld::zTextRenderer( int index ) const
|
|
|
+{
|
|
|
+ if( tm->renderer && tm->renderer->z( index ) )
|
|
|
+ return tm->renderer->z( index );
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
unsigned char TextFeld::getSchriftSize() const // gibt die Schriftgröße zurück
|
|
|
{
|
|
|
- return schriftSize;
|
|
|
+ tm->resetIteration();
|
|
|
+ return tm->current.fontSize;
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt die Schriftgröße zurück
|
|
|
+// index: Der Index des Zeichens
|
|
|
+unsigned char TextFeld::getSchriftSize( int index ) const
|
|
|
+{
|
|
|
+ tm->resetIteration();
|
|
|
+ return tm->current.fontSize;
|
|
|
}
|
|
|
|
|
|
int TextFeld::getSchriftFarbe() const// gibt getThis der Schriftfarbe zurück
|
|
|
{
|
|
|
- return sF;
|
|
|
+ tm->resetIteration();
|
|
|
+ return tm->current.fontColor;
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt die Schriftfarbe im A8R8G8B8 Format zurück
|
|
|
+// index: Der Index des Zeichens
|
|
|
+int TextFeld::getSchriftFarbe( int index ) const
|
|
|
+{
|
|
|
+ return tm->getTextStyle( index ).fontColor;
|
|
|
}
|
|
|
|
|
|
unsigned char TextFeld::getShowChar() const // gibt den Anzeige Char zurück
|
|
|
{
|
|
|
- return showChar;
|
|
|
+ return showChar;
|
|
|
}
|
|
|
|
|
|
int TextFeld::getCursorPos() const
|
|
|
{
|
|
|
- return cpos;
|
|
|
+ return cpos;
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt 1 zurück wenn das Zeichen ausgewählt ist
|
|
|
+// index: Der Index des Zeichens
|
|
|
+bool TextFeld::isCharSelected( int index ) const
|
|
|
+{
|
|
|
+ return tm->getTextStyle( index ).selected;
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt den Index des Zeichens zurück, das sich unter der Maus befindet
|
|
|
+// mx: die x position der maus relativ zur position des textfeldes
|
|
|
+// my: die y position der maus relativ zut position des textfeldes
|
|
|
+// return: -1, falls sich an der Position kein zeichen befindet
|
|
|
+int TextFeld::getTextIndexAt( int mx, int my ) const
|
|
|
+{
|
|
|
+ int tbr = getTextWidth();
|
|
|
+ int thi = getTextHeight();
|
|
|
+ int xxx = 0;
|
|
|
+ int yyy = 0;
|
|
|
+ int breite = innenSize.x;
|
|
|
+ int height = innenSize.y;
|
|
|
+ bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
|
|
|
+ bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
|
|
|
+ if( vs )
|
|
|
+ yyy -= vertikalScrollBar->getScroll();
|
|
|
+ if( hs )
|
|
|
+ xxx -= horizontalScrollBar->getScroll();
|
|
|
+ if( hatStyle( Style::HCenter ) && !hs )
|
|
|
+ xxx = ( breite / 2 ) - tbr / 2;
|
|
|
+ if( hatStyle( Style::VCenter ) && !vs )
|
|
|
+ yyy = ( height / 2 ) - thi / 2;
|
|
|
+ int x = xxx;
|
|
|
+ int y = yyy;
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ tm->resetIteration();
|
|
|
+ int maxLH = 0;
|
|
|
+ for( int i = 0; i < len; i++ )
|
|
|
+ {
|
|
|
+ int tmpx = tm->zCurrentRenderer()->getCharWidth( istSchreibbar( showChar ) ? showChar : text[ i ] );
|
|
|
+ int tmpy = tm->zCurrentRenderer()->getZeilenHeight();
|
|
|
+ if( mx >= x && mx < x + tmpx && my >= y && my < maxLH + tmpy )
|
|
|
+ return i;
|
|
|
+ if( mx < x + tmpx && my < maxLH + tmpy )
|
|
|
+ return -1;
|
|
|
+ x += tmpx + tm->zCurrentRenderer()->getZeichenAbstand();
|
|
|
+ tmpy += tm->zCurrentRenderer()->getZeilenAbstand();
|
|
|
+ maxLH = tmpy > maxLH ? tmpy : maxLH;
|
|
|
+ if( text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ x = xxx;
|
|
|
+ y += maxLH;
|
|
|
+ }
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
+// Gibt den Index des Zeichens zurück, vor dem der curser gesetzt wird, wenn mit der maus geklickt wird
|
|
|
+// mx: die x position der maus relativ zur position des textfeldes
|
|
|
+// my: die y position der maus relativ zut position des textfeldes
|
|
|
+int TextFeld::getCurserPosAt( int mx, int my ) const
|
|
|
+{
|
|
|
+ int tbr = getTextWidth();
|
|
|
+ int thi = getTextHeight();
|
|
|
+ int xxx = 0;
|
|
|
+ int yyy = 0;
|
|
|
+ int breite = innenSize.x;
|
|
|
+ int height = innenSize.y;
|
|
|
+ bool hs = horizontalScrollBar && hatStyle( Style::HScroll );
|
|
|
+ bool vs = vertikalScrollBar && hatStyle( Style::VScroll );
|
|
|
+ if( vs )
|
|
|
+ yyy -= vertikalScrollBar->getScroll();
|
|
|
+ if( hs )
|
|
|
+ xxx -= horizontalScrollBar->getScroll();
|
|
|
+ if( hatStyle( Style::HCenter ) && !hs )
|
|
|
+ xxx = ( breite / 2 ) - tbr / 2;
|
|
|
+ if( hatStyle( Style::VCenter ) && !vs )
|
|
|
+ yyy = ( height / 2 ) - thi / 2;
|
|
|
+ int x = xxx;
|
|
|
+ int y = yyy;
|
|
|
+ int len = tm->text->getLength();
|
|
|
+ char *text = tm->text->getText();
|
|
|
+ tm->resetIteration();
|
|
|
+ int maxLH = 0;
|
|
|
+ for( int i = 0; i < len; i++ )
|
|
|
+ {
|
|
|
+ int tmpx = tm->zCurrentRenderer()->getCharWidth( istSchreibbar( showChar ) ? showChar : text[ i ] );
|
|
|
+ int tmpy = tm->zCurrentRenderer()->getZeilenHeight() + tm->zCurrentRenderer()->getZeilenAbstand();
|
|
|
+ if( mx < x + tmpx / 2 && my < y + tmpy - tm->zCurrentRenderer()->getZeilenAbstand() / 2 )
|
|
|
+ return i;
|
|
|
+ x += tmpx + tm->zCurrentRenderer()->getZeichenAbstand();
|
|
|
+ maxLH = tmpy > maxLH ? tmpy : maxLH;
|
|
|
+ if( text[ i ] == '\n' )
|
|
|
+ {
|
|
|
+ if( my >= y - tm->zCurrentRenderer()->getZeilenAbstand() / 2 && my < y + maxLH - tm->zCurrentRenderer()->getZeilenAbstand() / 2 )
|
|
|
+ return i;
|
|
|
+ x = xxx;
|
|
|
+ y += maxLH;
|
|
|
+ }
|
|
|
+ tm->nextStyle();
|
|
|
+ }
|
|
|
+ return tm->text->getLength();
|
|
|
}
|
|
|
|
|
|
-int TextFeld::getSelectionPos() const
|
|
|
+// Gibt den Style eines bestimmten zeichens zurück
|
|
|
+// index: Der index des Zeichensf
|
|
|
+TextFeld::TextStyle TextFeld::getTextStyle( int index ) const
|
|
|
{
|
|
|
- return begf;
|
|
|
+ return tm->getTextStyle( index );
|
|
|
}
|
|
|
|
|
|
Zeichnung *TextFeld::dublizieren() const // Erzeugt eine Kopie des Zeichnungs
|
|
|
{
|
|
|
- TextFeld *obj = new TextFeld();
|
|
|
- obj->setPosition( pos );
|
|
|
- obj->setSize( gr );
|
|
|
- obj->setMausEreignisParameter( makParam );
|
|
|
- obj->setTastaturEreignisParameter( takParam );
|
|
|
- obj->setMausEreignis( mak );
|
|
|
- obj->setTastaturEreignis( tak );
|
|
|
- if( toolTip )
|
|
|
- obj->setToolTipZ( (ToolTip*)toolTip->dublizieren() );
|
|
|
- obj->setStyle( style );
|
|
|
- obj->setSchriftSize( schriftSize );
|
|
|
- if( textRd )
|
|
|
- obj->setSchriftZ( textRd->getSchrift() );
|
|
|
- if( text )
|
|
|
- obj->setText( text->getText() );
|
|
|
- obj->setHintergrundFarbe( hintergrundFarbe );
|
|
|
- obj->setSchriftFarbe( sF );
|
|
|
- if( hintergrundFeld )
|
|
|
- obj->setAlphaFeldZ( (AlphaFeld*)hintergrundFeld->dublizieren() );
|
|
|
- if( rahmen )
|
|
|
- obj->setRahmenZ( (Rahmen*)rahmen->dublizieren() );
|
|
|
- if( hintergrundBild )
|
|
|
- obj->setHintergrundBild( hintergrundBild->getThis() );
|
|
|
- if( vertikalScrollBar )
|
|
|
- {
|
|
|
- obj->setVertikalKlickScroll( vertikalScrollBar->getKlickScroll() );
|
|
|
- obj->setVertikalScrollPos( vertikalScrollBar->getScroll() );
|
|
|
- obj->setVertikalScrollFarbe( vertikalScrollBar->getFarbe(), vertikalScrollBar->getBgFarbe() );
|
|
|
- }
|
|
|
- if( horizontalScrollBar )
|
|
|
- {
|
|
|
- obj->setHorizontalKlickScroll( horizontalScrollBar->getKlickScroll() );
|
|
|
- obj->setHorizontalScrollPos( horizontalScrollBar->getScroll() );
|
|
|
- obj->setHorizontalScrollFarbe( horizontalScrollBar->getFarbe(), horizontalScrollBar->getBgFarbe() );
|
|
|
- }
|
|
|
- obj->setSchowChar( showChar );
|
|
|
- obj->setAuswahl( begf, cpos );
|
|
|
- return obj;
|
|
|
+ TextFeld *obj = new TextFeld();
|
|
|
+ obj->setPosition( pos );
|
|
|
+ obj->setSize( gr );
|
|
|
+ obj->setMausEreignisParameter( makParam );
|
|
|
+ obj->setTastaturEreignisParameter( takParam );
|
|
|
+ obj->setMausEreignis( mak );
|
|
|
+ obj->setTastaturEreignis( tak );
|
|
|
+ if( toolTip )
|
|
|
+ obj->setToolTipZ( (ToolTip*)toolTip->dublizieren() );
|
|
|
+ obj->setStyle( style );
|
|
|
+ obj->tm->renderer->release();
|
|
|
+ obj->tm->renderer = tm->renderer->getThis();
|
|
|
+ obj->tm->textStyle.leeren();
|
|
|
+ for( auto i = tm->textStyle.getIterator(); i; i++ )
|
|
|
+ obj->tm->textStyle.add( i._ );
|
|
|
+ obj->tm->index = tm->index;
|
|
|
+ obj->tm->styleIndex = tm->styleIndex;
|
|
|
+ obj->tm->current = tm->current;
|
|
|
+ if( tm->text )
|
|
|
+ obj->setText( tm->text->getText() );
|
|
|
+ obj->setHintergrundFarbe( hintergrundFarbe );
|
|
|
+ if( hintergrundFeld )
|
|
|
+ obj->setAlphaFeldZ( (AlphaFeld*)hintergrundFeld->dublizieren() );
|
|
|
+ if( rahmen )
|
|
|
+ obj->setRahmenZ( (Rahmen*)rahmen->dublizieren() );
|
|
|
+ if( hintergrundBild )
|
|
|
+ obj->setHintergrundBild( hintergrundBild->getThis() );
|
|
|
+ if( vertikalScrollBar )
|
|
|
+ {
|
|
|
+ obj->setVertikalKlickScroll( vertikalScrollBar->getKlickScroll() );
|
|
|
+ obj->setVertikalScrollPos( vertikalScrollBar->getScroll() );
|
|
|
+ obj->setVertikalScrollFarbe( vertikalScrollBar->getFarbe(), vertikalScrollBar->getBgFarbe() );
|
|
|
+ }
|
|
|
+ if( horizontalScrollBar )
|
|
|
+ {
|
|
|
+ obj->setHorizontalKlickScroll( horizontalScrollBar->getKlickScroll() );
|
|
|
+ obj->setHorizontalScrollPos( horizontalScrollBar->getScroll() );
|
|
|
+ obj->setHorizontalScrollFarbe( horizontalScrollBar->getFarbe(), horizontalScrollBar->getBgFarbe() );
|
|
|
+ }
|
|
|
+ obj->setSchowChar( showChar );
|
|
|
+ return obj;
|
|
|
}
|