Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Someone
Thursday, February 28th, 2008 at 7:27:00pm MST 

  1. --- Shell2.java 2008-02-28 21:22:18.000000000 -0500
  2. +++ Shell.java  2008-02-28 21:21:45.000000000 -0500
  3. @@ -114,12 +114,11 @@
  4.   * @see SWT
  5.  
  6.   */
  7.  
  8.  public class Shell extends Decorations {
  9.  
  10. -       int /*long*/ shellHandle, tooltipsHandle, tooltipWindow;
  11.  
  12. -       boolean mapped, moved, resized, opened;
  13.  
  14. +       int /*long*/ shellHandle, tooltipsHandle, tooltipWindow, group, modalGroup;
  15. +       boolean mapped, moved, resized, opened, fullScreen, showWithParent;
  16.         int oldX, oldY, oldWidth, oldHeight;
  17.  
  18.         int minWidth, minHeight;
  19.  
  20.         Control lastActive;
  21.  
  22. -       Region region;
  23.  
  24.  
  25.  
  26.         static final int MAXIMUM_TRIM = 128;
  27.  
  28.  
  29.  
  30. @@ -355,6 +354,7 @@
  31.  
  32.  
  33.  static int checkStyle (int style) {
  34.  
  35.         style = Decorations.checkStyle (style);
  36.  
  37. +       style &= ~SWT.TRANSPARENT;
  38.         if ((style & SWT.ON_TOP) != 0) style &= ~SWT.SHELL_TRIM;
  39.  
  40.         int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
  41.  
  42.         int bits = style & ~mask;
  43.  
  44. @@ -609,11 +609,6 @@
  45.                       OS.gtk_style_get_black (OS.gtk_widget_get_style (shellHandle), color);
  46.  
  47.                       OS.gtk_widget_modify_bg (shellHandle,  OS.GTK_STATE_NORMAL, color);
  48.  
  49.                }
  50.  
  51. -              int bits = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
  52.  
  53. -              boolean modal = (style & bits) != 0;
  54.  
  55. -              //TEMPORARY CODE
  56.  
  57. -              if ((style & SWT.ON_TOP) == 0) modal |= (parent != null && (parent.style & bits) != 0);
  58.  
  59. -              OS.gtk_window_set_modal (shellHandle, modal);
  60.  
  61.         } else {
  62.  
  63.                vboxHandle = OS.gtk_bin_get_child (shellHandle);
  64.  
  65.                if (vboxHandle == 0) error (SWT.ERROR_NO_HANDLES);
  66.  
  67. @@ -626,6 +621,8 @@
  68.                handle = OS.gtk_bin_get_child (scrolledHandle);
  69.  
  70.                if (handle == 0) error (SWT.ERROR_NO_HANDLES);
  71.  
  72.         }
  73.  
  74. +       group = OS.gtk_window_group_new ();
  75. +       if (group == 0) error (SWT.ERROR_NO_HANDLES);
  76.         /*
  77.  
  78.        * Feature in GTK.  Realizing the shell triggers a size allocate event,
  79.  
  80.        * which may be confused for a resize event from the window manager if
  81.  
  82. @@ -761,6 +758,14 @@
  83.        }
  84.  
  85. }
  86.  
  87.  
  88.  
  89. +int /*long*/ fixedSizeAllocateProc(int /*long*/ widget, int /*long*/ allocationPtr) {
  90. +       int clientWidth = 0;
  91. +       if ((style & SWT.MIRRORED) != 0) clientWidth = getClientWidth ();
  92. +       int /*long*/ result = super.fixedSizeAllocateProc (widget, allocationPtr);
  93. +       if ((style & SWT.MIRRORED) != 0) moveChildren (clientWidth);
  94. +       return result;
  95. +}
  96. +
  97.  void fixStyle (int /*long*/ handle) {
  98.  
  99.  }
  100.  
  101.  
  102.  
  103. @@ -780,6 +785,21 @@
  104.         OS.gtk_widget_size_allocate (vboxHandle, allocation);
  105.  
  106.  }
  107.  
  108.  
  109.  
  110. +public int getAlpha () {
  111. +       checkWidget ();
  112. +       if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
  113. +              if (OS.gtk_widget_is_composited (shellHandle)) {
  114. +                     return (int) (OS.gtk_window_get_opacity (shellHandle) * 255);
  115. +              }
  116. +       }
  117. +       return 255
  118. +}
  119. +
  120. +public boolean getFullScreen () {
  121. +       checkWidget();
  122. +       return fullScreen;
  123. +}
  124. +
  125.  public Point getLocation () {
  126.  
  127.         checkWidget ();
  128.  
  129.         int [] x = new int [1], y = new int [1];
  130.  
  131. @@ -787,6 +807,11 @@
  132.         return new Point (x [0], y [0]);
  133.  
  134.  }
  135.  
  136.  
  137.  
  138. +public boolean getMaximized () {
  139. +       checkWidget();
  140. +       return !fullScreen && super.getMaximized ();
  141. +}
  142. +
  143.  /**
  144.  
  145.   * Returns a point describing the minimum receiver's size. The
  146.  
  147.   * x coordinate of the result is the minimum width of the receiver.
  148.  
  149. @@ -809,6 +834,34 @@
  150.        return new Point (width, height);
  151.  
  152. }
  153.  
  154.  
  155.  
  156. +Shell getModalShell () {
  157. +       Shell shell = null;
  158. +       Shell [] modalShells = display.modalShells;
  159. +       if (modalShells != null) {
  160. +              int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
  161. +              int index = modalShells.length;
  162. +              while (--index >= 0) {
  163. +                     Shell modal = modalShells [index];
  164. +                     if (modal != null) {
  165. +                            if ((modal.style & bits) != 0) {
  166. +                                   Control control = this;
  167. +                                   while (control != null) {
  168. +                                          if (control == modal) break;
  169. +                                          control = control.parent;
  170. +                                   }
  171. +                                   if (control != modal) return modal;
  172. +                                   break;
  173. +                            }
  174. +                            if ((modal.style & SWT.PRIMARY_MODAL) != 0) {
  175. +                                   if (shell == null) shell = getShell ();
  176. +                                   if (modal.parent == shell) return modal;
  177. +                            }
  178. +                     }
  179. +              }
  180. +       }
  181. +       return null;
  182. +}
  183. +
  184. public Point getSize () {
  185.  
  186.        checkWidget ();
  187.  
  188.        int width = OS.GTK_WIDGET_WIDTH (vboxHandle);
  189.  
  190. @@ -840,6 +893,7 @@
  191.   *
  192.  
  193.   */
  194.  
  195.  public Region getRegion () {
  196.  
  197. +       /* This method is needed for @since 3.0 Javadoc */
  198.         checkWidget ();
  199.  
  200.         return region;
  201.  
  202.  }
  203.  
  204. @@ -967,7 +1021,6 @@
  205.  
  206.  
  207.  int /*long*/ gtk_map_event (int /*long*/ widget, int /*long*/ event) {
  208.  
  209.         minimized = false;
  210.  
  211. -       sendEvent (SWT.Deiconify);
  212.  
  213.         return 0;
  214.  
  215.  }
  216.  
  217.  
  218.  
  219. @@ -1012,7 +1065,6 @@
  220.  
  221.  
  222.  int /*long*/ gtk_unmap_event (int /*long*/ widget, int /*long*/ event) {
  223.  
  224.         minimized = true;
  225.  
  226. -       sendEvent (SWT.Iconify);
  227.  
  228.         return 0;
  229.  
  230.  }
  231.  
  232.  
  233.  
  234. @@ -1021,6 +1073,14 @@
  235.         OS.memmove (gdkEvent, event, GdkEventWindowState.sizeof);
  236.  
  237.         minimized = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_ICONIFIED) != 0;
  238.  
  239.         maximized = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_MAXIMIZED) != 0;
  240.  
  241. +       fullScreen = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_FULLSCREEN) != 0;
  242. +       if ((gdkEvent.changed_mask & OS.GDK_WINDOW_STATE_ICONIFIED) != 0) {
  243. +              if (minimized) {
  244. +                     sendEvent (SWT.Iconify);
  245. +              } else {
  246. +                     sendEvent (SWT.Deiconify);
  247. +              }
  248. +       }
  249.         return 0;
  250.  
  251.  }
  252.  
  253.  
  254.  
  255. @@ -1144,6 +1204,16 @@
  256.         }
  257.  
  258.  }
  259.  
  260.  
  261.  
  262. +public void setAlpha (int alpha) {
  263. +       checkWidget ();
  264. +       if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
  265. +              if (OS.gtk_widget_is_composited (shellHandle)) {
  266. +                     alpha &= 0xFF;
  267. +                     OS.gtk_window_set_opacity (shellHandle, alpha / 255f);
  268. +              }
  269. +       }
  270. +}
  271. +
  272.  void resizeBounds (int width, int height, boolean notify) {
  273.  
  274.         if (redrawWindow != 0) {
  275.  
  276.                OS.gdk_window_resize (redrawWindow, width, height);
  277.  
  278. @@ -1168,6 +1238,7 @@
  279.  }
  280.  
  281.  
  282.  
  283.  int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
  284.  
  285. +       if (fullScreen) setFullScreen (false);
  286.         /*
  287.  
  288.        * Bug in GTK.  When either of the location or size of
  289.  
  290.        * a shell is changed while the shell is maximized, the
  291.  
  292. @@ -1281,6 +1352,19 @@
  293.        }
  294.  
  295. }
  296.  
  297.  
  298.  
  299. +public void setFullScreen (boolean fullScreen) {
  300. +       checkWidget();
  301. +       if (fullScreen) {
  302. +              OS.gtk_window_fullscreen (shellHandle);
  303. +       } else {
  304. +              OS.gtk_window_unfullscreen (shellHandle);
  305. +              if (maximized) {
  306. +                     setMaximized (true);
  307. +              }
  308. +       }
  309. +       this.fullScreen = fullScreen;
  310. +}
  311. +
  312. /**
  313.  
  314.   * Sets the input method editor mode to the argument which
  315.  
  316.   * should be the result of bitwise OR'ing together one or more
  317.  
  318. @@ -1429,11 +1513,7 @@
  319. public void setRegion (Region region) {
  320.  
  321.        checkWidget ();
  322.  
  323.        if ((style & SWT.NO_TRIM) == 0) return;
  324.  
  325. -       if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
  326.  
  327. -       int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);
  328.  
  329. -       int /*long*/ shape_region = (region == null) ? 0 : region.handle;
  330.  
  331. -       OS.gdk_window_shape_combine_region (window, shape_region, 0, 0);
  332.  
  333. -       this.region = region;
  334.  
  335. +       super.setRegion (region);
  336.  }
  337.  
  338.  
  339.  
  340.  /*
  341.  
  342. @@ -1463,6 +1543,18 @@
  343. public void setVisible (boolean visible) {
  344.  
  345.        checkWidget();
  346.  
  347.        if ((OS.GTK_WIDGET_MAPPED (shellHandle) == visible)) return;
  348.  
  349. +       int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
  350. +       if ((style & mask) != 0) {
  351. +              if (visible) {
  352. +                     display.setModalShell (this);
  353. +                     OS.gtk_window_set_modal (shellHandle, true);
  354. +              } else {
  355. +                     display.clearModal (this);
  356. +                     OS.gtk_window_set_modal (shellHandle, false);
  357. +              }
  358. +       } else {
  359. +              updateModal ();
  360. +       }
  361.        if (visible) {
  362.  
  363.               sendEvent (SWT.Show);
  364.  
  365.               if (isDisposed ()) return;
  366.  
  367. @@ -1479,6 +1571,7 @@
  368.               * unminimized or shown on the desktop.
  369.  
  370.               */
  371.  
  372.                OS.gtk_widget_show (shellHandle);
  373.  
  374. +              if (enableWindow != 0) OS.gdk_window_raise (enableWindow);
  375.                if (!OS.GTK_IS_PLUG (shellHandle)) {
  376.  
  377.                       mapped = false;
  378.  
  379.                       if (isDisposed ()) return;
  380.  
  381. @@ -1509,7 +1602,6 @@
  382.                }
  383.  
  384.                mapped = true;
  385.  
  386.  
  387.  
  388. -              int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
  389.  
  390.                if ((style & mask) != 0) {
  391.  
  392.                       OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME);
  393.  
  394.                }
  395.  
  396. @@ -1603,6 +1695,7 @@
  397.  }
  398.  
  399.  int trimHeight () {
  400.  
  401.         if ((style & SWT.NO_TRIM) != 0) return 0;
  402.  
  403. +       if (fullScreen) return 0;
  404.         boolean hasTitle = false, hasResize = false, hasBorder = false;
  405.  
  406.         hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
  407.  
  408.         hasResize = (style & SWT.RESIZE) != 0;
  409.  
  410. @@ -1619,6 +1712,7 @@
  411.  
  412.  
  413.  int trimWidth () {
  414.  
  415.         if ((style & SWT.NO_TRIM) != 0) return 0;
  416.  
  417. +       if (fullScreen) return 0;
  418.         boolean hasTitle = false, hasResize = false, hasBorder = false;
  419.  
  420.         hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
  421.  
  422.         hasResize = (style & SWT.RESIZE) != 0;
  423.  
  424. @@ -1633,6 +1727,71 @@
  425.         return 0;
  426.  
  427.  }
  428.  
  429.  
  430.  
  431. +void updateModal () {
  432. +       int /*long*/ group = 0;
  433. +       if (display.getModalDialog () == null) {
  434. +              Shell modal = getModalShell ();
  435. +              int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
  436. +              Composite shell = null;
  437. +              if (modal == null) {
  438. +                     if ((style & mask) != 0) shell = this;
  439. +              } else {
  440. +                     shell = modal;
  441. +              }
  442. +              while (shell != null) {
  443. +                     if ((shell.style & mask) == 0) {
  444. +                            group = shell.getShell ().group;
  445. +                            break;
  446. +                     }
  447. +                     shell = shell.parent;
  448. +              }
  449. +       }
  450. +       if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0) && group == 0) {
  451. +              /*
  452. +              * Feature in GTK. Starting with GTK version 2.10, GTK
  453. +              * doesn't assign windows to a default group. The fix is to
  454. +              * get the handle of the default group and add windows to the
  455. +              * group.
  456. +              */
  457. +              group = OS.gtk_window_get_group(0);
  458. +       }
  459. +       if (group != 0) {
  460. +              OS.gtk_window_group_add_window (group, shellHandle);
  461. +       } else {
  462. +              if (modalGroup != 0) {
  463. +                     OS.gtk_window_group_remove_window (modalGroup, shellHandle);
  464. +              }
  465. +       }
  466. +       if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
  467. +              fixModal (group, modalGroup);
  468. +       }
  469. +       modalGroup = group;
  470. +}
  471. +
  472. +void updateShells () {
  473. +       Shell [] shells = getShells ();
  474. +       for (int i=0; i<shells.length; i++) {
  475. +              boolean update = false;
  476. +              Shell shell = shells [i];
  477. +              if (shell.isUndecorated ()) {
  478. +                     update = true;
  479. +              } else {
  480. +                     do {
  481. +                            shell = (Shell) shell.getParent ();
  482. +                     } while (shell != null && shell != this && !shell.isUndecorated ());
  483. +                     if (shell != null && shell != this) update = true;
  484. +              }
  485. +              if (update) {
  486. +                     if (minimized) {
  487. +                            OS.gtk_widget_hide (shells [i].shellHandle);
  488. +                     } else if (showWithParent) {
  489. +                            OS.gtk_widget_show (shells [i].shellHandle);
  490. +                     }
  491. +              }
  492. +       }
  493. +       showWithParent = minimized;
  494. +}
  495. +
  496.  void deregister () {
  497.  
  498.         super.deregister ();
  499.  
  500.         display.removeWidget (shellHandle);
  501.  
  502. @@ -1707,19 +1866,32 @@
  503.  void releaseWidget () {
  504.  
  505.         super.releaseWidget ();
  506.  
  507.         destroyAccelGroup ();
  508.  
  509. +       display.clearModal (this);
  510.         if (display.activeShell == this) display.activeShell = null;
  511.  
  512.         if (tooltipsHandle != 0) OS.g_object_unref (tooltipsHandle);
  513.  
  514.         tooltipsHandle = 0;
  515.  
  516. +       if (group != 0) OS.g_object_unref (group);
  517. +       group = modalGroup = 0;
  518.         int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);
  519.  
  520.         OS.gdk_window_remove_filter(window, display.filterProc, shellHandle);
  521.  
  522. -       region = null;
  523.  
  524.         lastActive = null;
  525.  
  526.  }
  527.  
  528.  
  529.  
  530.  void setToolTipText (int /*long*/ widget, String string) {
  531.  
  532. +       if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
  533. +              byte [] buffer = null;
  534. +              if (string != null && string.length () > 0) {
  535. +                     char [] chars = fixMnemonic (string, false);
  536. +                     buffer = Converter.wcsToMbcs (null, chars, true);
  537. +              }
  538. +              OS.gtk_widget_set_tooltip_text (widget, null);
  539. +              OS.gtk_tooltip_trigger_tooltip_query (OS.gdk_display_get_default ());
  540. +              OS.gtk_widget_set_tooltip_text (widget, buffer);       
  541. +       } else {
  542.         byte [] buffer = null;
  543.  
  544.         if (string != null && string.length () > 0) {
  545.  
  546. -              buffer = Converter.wcsToMbcs (null, string, true);
  547.  
  548. +                     char [] chars = fixMnemonic (string, false);
  549. +                     buffer = Converter.wcsToMbcs (null, chars, true);
  550.         }
  551.  
  552.         if (tooltipsHandle == 0) {
  553.  
  554.                tooltipsHandle = OS.gtk_tooltips_new ();
  555.  
  556. @@ -1781,5 +1953,7 @@
  557.                }
  558.  
  559.         }
  560.  
  561.         if (set) OS.gtk_tooltips_set_tip (tooltipsHandle, widget, buffer, null);
  562.  
  563. +       }
  564. +              
  565.  }
  566.  
  567.  }

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
worth-right
fantasy-obligation
fantasy-obligation