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

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

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

revision 1.4 by smarothy, Sun Aug 21 00:19:49 2005 UTC revision 1.5 by smarothy, Tue Aug 23 02:13:48 2005 UTC
# Line 56  exception statement from your version. * Line 56  exception statement from your version. *
56  /*  /*
57   * Our QMainWindow subclass   * Our QMainWindow subclass
58   */   */
59  class MyWindow : public QMainWindow  class MyFrame : public QMainWindow
60  {  {
61  public:  public:
62    MyWindow(JNIEnv *env, jobject obj) : QMainWindow(0, Qt::Window )    MyFrame(JNIEnv *env, jobject obj) : QMainWindow(0, Qt::Window )
63    {    {
64      setup(env, obj);      setup(env, obj);
65    }    }
66    
67    ~MyWindow()    ~MyFrame()
68    {    {
69      destroy();      destroy();
70    }    }
# Line 101  class FrameMenuEvent : public AWTEvent { Line 101  class FrameMenuEvent : public AWTEvent {
101  };  };
102    
103  /**  /**
  * Event wrapper for getting the menu bar height  
  */  
 class FrameGetMenuHeightEvent : public AWTEvent {  
     
 private:  
   QMainWindow *frame;  
   int **value;  
     
 public:  
   FrameGetMenuHeightEvent(QMainWindow *w, int **v) : AWTEvent()  
   {  
     frame = w;  
     value = v;  
   }  
   
   void runEvent()  
   {  
     QMenuBar *mb = frame->menuBar();  
     assert( mb );  
     int *v = (int *)malloc( sizeof( int ) );  
     *v = mb->sizeHint().height();  
     *value = v;  
   }  
 };  
   
 /**  
104   * Returns the child widget for the frame (the centralWidget in qt terms)   * Returns the child widget for the frame (the centralWidget in qt terms)
105   */   */
106  QWidget *frameChildWidget( JNIEnv *env, jobject component )  QWidget *frameChildWidget( JNIEnv *env, jobject component )
# Line 142  QWidget *frameChildWidget( JNIEnv *env, Line 116  QWidget *frameChildWidget( JNIEnv *env,
116    if( framepeerobj == NULL )    if( framepeerobj == NULL )
117      return (QWidget *)NULL;      return (QWidget *)NULL;
118    
119    MyWindow *window = (MyWindow *)getNativeObject(env, framepeerobj);    MyFrame *window = (MyFrame *)getNativeObject(env, framepeerobj);
120    assert( window );    assert( window );
121    return window;    return window;
122  }  }
# Line 153  QWidget *frameChildWidget( JNIEnv *env, Line 127  QWidget *frameChildWidget( JNIEnv *env,
127  JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_init  JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtFramePeer_init
128  (JNIEnv *env, jobject obj)  (JNIEnv *env, jobject obj)
129  {  {
130    MyWindow *frame = new MyWindow(env, obj);    MyFrame *frame = new MyFrame(env, obj);
131    assert( frame );    assert( frame );
132      frame->addToolBarBreak ( Qt::BottomToolBarArea );
   QWidget *central = new QWidget( frame );  
   assert( central );  
   
133    setNativeObject( env, obj, frame );    setNativeObject( env, obj, frame );
134  }  }
135    
# Line 197  JNIEXPORT jint JNICALL Java_gnu_java_awt Line 168  JNIEXPORT jint JNICALL Java_gnu_java_awt
168    QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );    QMainWindow *frame = (QMainWindow *) getNativeObject( env, obj );
169    assert( frame );    assert( frame );
170    
171    int *value = NULL;    QMenuBar *mb = frame->menuBar();
   mainThread->postEventToMain( new FrameGetMenuHeightEvent( frame, &value ) );  
   
   while(value == NULL); // (Busy) wait for the value to  
   // get set by the main thread.  
172    
173    return (jint)(*value);    return ( mb != NULL ) ? mb->sizeHint().height() : 0 ;
174  }  }
175    
176  /*  /*

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

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