From 3728914b67bd00a8b771027767ab899d29ec9d30 Mon Sep 17 00:00:00 2001
From: Grant Gayed
- * Shadow styles are hints and may not be honoured by the platform. To create a
- * group with the default shadow style for the platform, do not specify a shadow
- * style.
- *
- * Note: Only one of the above styles may be specified.
- *
- * IMPORTANT: This class is not intended to be subclassed.
- *
- * The style value is either one of the style constants defined in class
- *
- *
- * SWT
which is applicable to instances of this class, or must
- * be built by bitwise OR'ing together (that is, using the
- * int
"|" operator) two or more of those SWT
- * style constants. The class description lists the style constants that are
- * applicable to the class. Style bits are also inherited from superclasses.
- *
- *
- * @exception SWTException
- *
- *
- *
- * @see SWT#SHADOW_ETCHED_IN
- * @see SWT#SHADOW_ETCHED_OUT
- * @see SWT#SHADOW_IN
- * @see SWT#SHADOW_OUT
- * @see SWT#SHADOW_NONE
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
- public Group(Composite parent, int style) {
- super(parent, checkStyle(style));
- }
-
- @Override
- protected QWidget createQWidget(int style) {
- state |= DRAW_BACKGROUND;
- state |= CANVAS;
- //TODO apply SWT.SHADOW_* styles
- return new QGroupBox();
- }
-
- QGroupBox getQGroupBox() {
- return (QGroupBox) getQWidget();
- }
-
- static int checkStyle(int style) {
- style |= SWT.NO_FOCUS;
- /*
- * Even though it is legal to create this widget with scroll bars, they
- * serve no useful purpose because they do not automatically scroll the
- * widget's client area. The fix is to clear the SWT style.
- */
- return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
- }
-
- @Override
- protected void checkSubclass() {
- if (!isValidSubclass()) {
- error(SWT.ERROR_INVALID_SUBCLASS);
- }
- }
-
- @Override
- public Rectangle getClientArea() {
- checkWidget();
- if (!isVisible()) {
- updateQLayouts();
- }
-
- Rectangle clientArea = QtSWTConverter.convert(getQWidget().contentsRect());
- if (clientArea.width < 0) {
- clientArea.width = 0;
- }
- if (clientArea.height < 0) {
- clientArea.height = 0;
- }
-
- return clientArea;
- }
-
- @Override
- public Rectangle computeTrim(int x, int y, int width, int height) {
- QContentsMargins margins = getQGroupBox().getContentsMargins();
- return new Rectangle(x - margins.left, y - margins.top, width + margins.left + margins.right, height
- + margins.top + margins.bottom);
- }
-
- @Override
- String getNameText() {
- return getText();
- }
-
- /**
- * Returns the receiver's text, which is the string that the is used as the
- * title. If the text has not previously been set, returns an empty
- * string.
- *
- * @return the text
- *
- * @exception SWTException
- *
- *
- */
- public String getText() {
- checkWidget();
- return getQGroupBox().title();
- }
-
- @Override
- boolean mnemonicHit(char key) {
- return setFocus();
- }
-
- @Override
- boolean mnemonicMatch(char key) {
- char mnemonic = findMnemonic(getText());
- if (mnemonic == '\0') {
- return false;
- }
- return Character.toUpperCase(key) == Character.toUpperCase(mnemonic);
- }
-
- void printWidget(int /* long */hwnd, int /* long */hdc, GC gc) {
- // TODO
- throw new UnsupportedOperationException("not yet implemented");//$NON-NLS-1$
- // /*
- // * Bug in Windows. For some reason, PrintWindow() returns success but
- // * does nothing when it is called on a printer. The fix is to just go
- // * directly to WM_PRINT in this case.
- // */
- // boolean success = false;
- // if ( !( OS.GetDeviceCaps( gc.handle, OS.TECHNOLOGY ) ==
- // OS.DT_RASPRINTER ) ) {
- // success = OS.PrintWindow( hwnd, hdc, 0 );
- // }
- //
- // /*
- // * Bug in Windows. For some reason, PrintWindow() fails when it is
- // * called on a push button. The fix is to detect the failure and use
- // * WM_PRINT instead. Note that WM_PRINT cannot be used all the time
- // * because it fails for browser controls when the browser has focus.
- // */
- // if ( !success ) {
- // /*
- // * Bug in Windows. For some reason, WM_PRINT when called with
- // * PRF_CHILDREN will not draw the tool bar divider for tool bar
- // * children that do not have CCS_NODIVIDER. The fix is to draw the
- // * group box and iterate through the children, drawing each one.
- // */
- // int flags = OS.PRF_CLIENT | OS.PRF_NONCLIENT | OS.PRF_ERASEBKGND;
- // OS.SendMessage( hwnd, OS.WM_PRINT, hdc, flags );
- // int nSavedDC = OS.SaveDC( hdc );
- // Control[] children = _getChildren();
- // Rectangle rect = getBounds();
- // OS.IntersectClipRect( hdc, 0, 0, rect.width, rect.height );
- // for ( int i = children.length - 1; i >= 0; --i ) {
- // Point location = children[i].getLocation();
- // int graphicsMode = OS.GetGraphicsMode( hdc );
- // if ( graphicsMode == OS.GM_ADVANCED ) {
- // float[] lpXform = { 1, 0, 0, 1, location.x, location.y };
- // OS.ModifyWorldTransform( hdc, lpXform, OS.MWT_LEFTMULTIPLY );
- // } else {
- // OS.SetWindowOrgEx( hdc, -location.x, -location.y, null );
- // }
- // int /* long */topHandle = children[i].topHandle();
- // int bits = OS.GetWindowLong( topHandle, OS.GWL_STYLE );
- // if ( ( bits & OS.WS_VISIBLE ) == 0 ) {
- // OS.DefWindowProc( topHandle, OS.WM_SETREDRAW, 1, 0 );
- // }
- // children[i].printWidget( topHandle, hdc, gc );
- // if ( ( bits & OS.WS_VISIBLE ) == 0 ) {
- // OS.DefWindowProc( topHandle, OS.WM_SETREDRAW, 0, 0 );
- // }
- // if ( graphicsMode == OS.GM_ADVANCED ) {
- // float[] lpXform = { 1, 0, 0, 1, -location.x, -location.y };
- // OS.ModifyWorldTransform( hdc, lpXform, OS.MWT_LEFTMULTIPLY );
- // }
- // }
- // OS.RestoreDC( hdc, nSavedDC );
- // }
- }
-
- @Override
- public void setFont(Font font) {
- checkWidget();
- Rectangle oldRect = getClientArea();
- super.setFont(font);
- Rectangle newRect = getClientArea();
- if (!oldRect.equals(newRect)) {
- sendResize();
- }
- }
-
- /**
- * Sets the receiver's text, which is the string that will be displayed as
- * the receiver's title, to the argument, which may not be null.
- * The string may include the mnemonic character.