/[classpath]/classpath/native/jni/qt-peer/qttextareapeer.cpp
ViewVC logotype

Diff of /classpath/native/jni/qt-peer/qttextareapeer.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2.2.1 by gnu_andrew, Tue Aug 16 16:22:39 2005 UTC revision 1.2.2.2 by gnu_andrew, Sat Sep 10 15:32:04 2005 UTC
# Line 35  this exception to your version of the li Line 35  this exception to your version of the li
35  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
36  exception statement from your version. */  exception statement from your version. */
37    
38    #include <assert.h>
39  #include <time.h>  #include <time.h>
40  #include <QTextEdit>  #include <QTextEdit>
41  #include <QTextCursor>  #include <QTextCursor>
42  #include <gnu_java_awt_peer_qt_QtTextAreaPeer.h>  #include <gnu_java_awt_peer_qt_QtTextAreaPeer.h>
43    #include "mainthreadinterface.h"
44    #include "componentevent.h"
45    #include "slotcallbacks.h"
46  #include "qtcomponent.h"  #include "qtcomponent.h"
47  #include "qtstrings.h"  #include "qtstrings.h"
48    
49  // FIXME: This stuff ain't thread safe.  class TASetText : public AWTEvent {
50     private:
51      QTextEdit *area;
52      QString *text;
53    
54     public:
55      TASetText(QTextEdit *w, QString *t) : AWTEvent()
56      {
57        area = w;
58        text = t;
59      }
60    
61      void runEvent()
62      {
63        area->setPlainText( *text );
64        delete text;
65      }
66    };
67    
68  /*  /*
69   * Construct a QTextEdit object   * Construct a QTextEdit object
# Line 57  JNIEXPORT void JNICALL Java_gnu_java_awt Line 78  JNIEXPORT void JNICALL Java_gnu_java_awt
78    assert( editor );    assert( editor );
79    
80    //  setLineWrapColumnOrWidth ( int w );    //  setLineWrapColumnOrWidth ( int w );
   
81    setNativeObject( env, obj, editor );    setNativeObject( env, obj, editor );
82    
83      // Connect TextChanged events.
84      connectTextEdit(editor, env, obj);
85  }  }
86    
87  /*  /*
# Line 123  JNIEXPORT jstring JNICALL Java_gnu_java_ Line 146  JNIEXPORT jstring JNICALL Java_gnu_java_
146  }  }
147    
148  /*  /*
  * Inserts text.  
  */  
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_insert  
 (JNIEnv *env, jobject obj, jstring str, jint index)  
 {  
   QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );  
   assert( editor );  
   
   QTextCursor curs = editor->textCursor();  
   int oldPos = curs.position();  
   curs.setPosition( index );  
   QString *qStr = getQString(env, str);  
   curs.insertText( *qStr );  
   delete qStr;  
   curs.setPosition( oldPos );  
 }  
   
 /*  
149   * Sets the editor text.   * Sets the editor text.
150   */   */
151  JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText  JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtTextAreaPeer_setText
# Line 150  JNIEXPORT void JNICALL Java_gnu_java_awt Line 155  JNIEXPORT void JNICALL Java_gnu_java_awt
155    assert( editor );    assert( editor );
156    
157    QString *qStr = getQString(env, str);    QString *qStr = getQString(env, str);
158    editor->setPlainText( *qStr );    mainThread->postEventToMain( new TASetText( editor, qStr ) );
   delete qStr;  
159  }  }
160    
161  /*  /*
# Line 162  JNIEXPORT void JNICALL Java_gnu_java_awt Line 166  JNIEXPORT void JNICALL Java_gnu_java_awt
166  {  {
167    QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );    QTextEdit *editor = (QTextEdit *) getNativeObject( env, obj );
168    assert( editor );    assert( editor );
169    // FIXME  
170  //   QTextCursor curs = editor->textCursor();    QTextCursor curs(editor->document());
171  //   editor->setSelection ( 0, startpos, 0, endpos );    curs.setPosition(startpos);
172      curs.setPosition(endpos, QTextCursor::KeepAnchor);
173      editor->setTextCursor( curs );
174  }  }
175    
176  /*  /*

Legend:
Removed from v.1.2.2.1  
changed lines
  Added in v.1.2.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26