javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Shell.java
changeset 47 f40128debb5d
parent 35 85266cc22c7f
child 48 e0d6e9bd3ca7
equal deleted inserted replaced
35:85266cc22c7f 47:f40128debb5d
   139  * provides access for Qt created draw surface.
   139  * provides access for Qt created draw surface.
   140  */
   140  */
   141 WindowSurface windowSurface;
   141 WindowSurface windowSurface;
   142 
   142 
   143 /**
   143 /**
       
   144  * When QMainWindow/QDialog visibility is changed, Qt may send a resize event.
       
   145  * eSWT application may have a Shell.setVisible() call in Shell's resize event
       
   146  * handler, which would cause an infinite loop. To prevent this suppress resize
       
   147  * events when Shell visibility is being changed.
       
   148  */
       
   149 boolean suppressResizeEvent;
       
   150 
       
   151 /**
   144  * Constructs a new instance of this class. This is equivalent
   152  * Constructs a new instance of this class. This is equivalent
   145  * to calling <code>Shell((Display) null)</code>.
   153  * to calling <code>Shell((Display) null)</code>.
   146  *
   154  *
   147  * @exception SWTException <ul>
   155  * @exception SWTException <ul>
   148  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
   156  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
   465         area.height /= 3;
   473         area.height /= 3;
   466     }
   474     }
   467     Point size =  computeSize(area.width, area.height, true);
   475     Point size =  computeSize(area.width, area.height, true);
   468     size.x -= windowFrameTrim() * 2;
   476     size.x -= windowFrameTrim() * 2;
   469     size.y -= windowTitleTrim() + windowFrameTrim();
   477     size.y -= windowTitleTrim() + windowFrameTrim();
       
   478     
       
   479     // These values will be returned if the size is queried before the Shell
       
   480     // is made visible (and they are not set again). 
       
   481     OS.QWidget_resize(topHandle, size.x, size.y);
       
   482     
   470     if(OS.windowServer == OS.WS_SYMBIAN_S60 && parent == null) {
   483     if(OS.windowServer == OS.WS_SYMBIAN_S60 && parent == null) {
   471         setRestoreState(OS.QT_WINDOWMAXIMIZED, false);
   484         setRestoreState(OS.QT_WINDOWMAXIMIZED, false);
   472     } else {
   485     }
   473         OS.QWidget_resize(topHandle, size.x, size.y);
   486 
   474     }
       
   475     return size;
   487     return size;
   476 }
   488 }
   477 
   489 
   478 public Rectangle computeTrim (int x, int y, int width, int height) {
   490 public Rectangle computeTrim (int x, int y, int width, int height) {
   479     checkWidget();
   491     checkWidget();
   989     } else {
  1001     } else {
   990         updateModal ();
  1002         updateModal ();
   991     }
  1003     }
   992     
  1004     
   993     // This shell
  1005     // This shell
   994     super.setVisible(visible);
  1006     try {
       
  1007         if (visible) {
       
  1008             suppressResizeEvent = true;
       
  1009         }
       
  1010         super.setVisible(visible);
       
  1011     } finally {
       
  1012         suppressResizeEvent = false;
       
  1013     }
       
  1014     
   995     if(isDisposed()) return;
  1015     if(isDisposed()) return;
   996         
  1016         
   997     // Dialog shells. 
  1017     // Dialog shells. 
   998     // SWT behavior is that when a Shell gets setVisible(false) then dialog Shells
  1018     // SWT behavior is that when a Shell gets setVisible(false) then dialog Shells
   999     // after that have getVisible == isVisible == false.  
  1019     // after that have getVisible == isVisible == false.  
  1130 
  1150 
  1131 public Rectangle internal_getDefaultBounds() {
  1151 public Rectangle internal_getDefaultBounds() {
  1132     return defBounds;
  1152     return defBounds;
  1133 }
  1153 }
  1134 
  1154 
       
  1155 void qt_swt_event_widgetResized_pp(int widgetHandle, int oldWidth, int oldHeight, int width, int height, boolean sendResizeEvent) {
       
  1156     super.qt_swt_event_widgetResized_pp(widgetHandle, oldWidth, oldHeight, width, height, !suppressResizeEvent);
       
  1157 }
       
  1158 
  1135 WindowSurface getWindowSurface() {
  1159 WindowSurface getWindowSurface() {
  1136 	checkWidget();
  1160 	checkWidget();
  1137 	// Only top level shells have window surface
  1161 	// Only top level shells have window surface
  1138 	if (parent != null) {
  1162 	if (parent != null) {
  1139 		return null;
  1163 		return null;