javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java
changeset 35 85266cc22c7f
parent 26 dc7c549001d5
child 47 f40128debb5d
child 49 35baca0e7a2e
equal deleted inserted replaced
26:dc7c549001d5 35:85266cc22c7f
    48  */
    48  */
    49 abstract public class ViewBase
    49 abstract public class ViewBase
    50 {
    50 {
    51     /** Maximum view height in percentage from display client area height. */
    51     /** Maximum view height in percentage from display client area height. */
    52     protected static final int MAX_VIEW_HEIGHT = 80;
    52     protected static final int MAX_VIEW_HEIGHT = 80;
       
    53     /** Maximum view width in percentage from display client area width. */
       
    54     protected static final int MAX_VIEW_WIDTH = 90;
    53     /** Parent shell for this view. */
    55     /** Parent shell for this view. */
    54     protected Shell iParent = null;
    56     protected Shell iParent = null;
    55     /** Container for the contents of the view */
    57     /** Container for the contents of the view */
    56     private Composite iContainer = null;
    58     private Composite iContainer = null;
    57     /** ScrolledComposite for iComposite. */
    59     /** ScrolledComposite for iComposite. */
   339             getAppInfoComposite().setSize(
   341             getAppInfoComposite().setSize(
   340                 getAppInfoComposite().computeSize(
   342                 getAppInfoComposite().computeSize(
   341                     SWT.DEFAULT, SWT.DEFAULT));
   343                     SWT.DEFAULT, SWT.DEFAULT));
   342         }
   344         }
   343 
   345 
   344         int contentWidth = iDefaultContentSize.x;
   346         int contentWidth = iDefaultContentSize.x * MAX_VIEW_WIDTH / 100;
   345         if (aVerticalScrollBarVisible)
   347         if (aVerticalScrollBarVisible)
   346         {
   348         {
   347             int verticalScrollBarWidth =
   349             int verticalScrollBarWidth =
   348                 getScrolledComposite().getVerticalBar().getSize().x;
   350                 getScrolledComposite().getVerticalBar().getSize().x;
   349             contentWidth = iDefaultContentSize.x - verticalScrollBarWidth;
   351             contentWidth -= verticalScrollBarWidth;
   350         }
   352         }
   351 
   353 
   352         // Recalculate the size of the content.
   354         // Recalculate the size of the content.
   353         Point contentSize = comp.computeSize(contentWidth, SWT.DEFAULT);
   355         Point contentSize = comp.computeSize(contentWidth, SWT.DEFAULT);
   354         comp.setSize(contentSize);
   356         comp.setSize(contentSize);
   355         Point cmdContentSize = cmdComp.computeSize(iDefaultContentSize.x, SWT.DEFAULT);
   357         Point cmdContentSize = cmdComp.computeSize(iDefaultContentSize.x, SWT.DEFAULT);
   356         cmdComp.setSize(cmdContentSize);
   358         cmdComp.setSize(cmdContentSize);
   357 
   359 
   358         // Adjust Shell height. The Shell never changes the x position, nor the width.
   360         // Adjust Shell height and width.
   359         Rectangle dispRect = shell.getDisplay().getClientArea();
   361         Rectangle dispRect = shell.getDisplay().getClientArea();
   360         int offset = iDefaultContentSize.y - contentSize.y - cmdContentSize.y;
   362         int offset = iDefaultContentSize.y - contentSize.y - cmdContentSize.y;
   361 
   363 
   362         Rectangle defShellBounds = iInstallerUi.getDefaultShellBounds();
   364         Rectangle defShellBounds = iInstallerUi.getDefaultShellBounds();
   363         int newHeight = defShellBounds.height - offset;
   365         int newHeight = defShellBounds.height - offset;
   366         if (newHeight > maxHeight)
   368         if (newHeight > maxHeight)
   367         {
   369         {
   368             offset -= maxHeight - newHeight;
   370             offset -= maxHeight - newHeight;
   369             newHeight = maxHeight;
   371             newHeight = maxHeight;
   370         }
   372         }
   371 
   373         int newWidth = defShellBounds.width;
       
   374         int maxWidth = dispRect.width * MAX_VIEW_WIDTH / 100;
       
   375         if (newWidth > maxWidth)
       
   376         {
       
   377             newWidth = maxWidth;
       
   378         }
       
   379 
       
   380         // Always center horizontally and vertically.
   372         Rectangle dispBounds = shell.getDisplay().getBounds();
   381         Rectangle dispBounds = shell.getDisplay().getBounds();
       
   382         int x = dispBounds.width - newWidth;
   373         int y = dispBounds.height - newHeight;
   383         int y = dispBounds.height - newHeight;
   374         // Always center vertically.
   384         x /= 2;
   375         y /= 2;
   385         y /= 2;
   376         // For landscape orientation center vertically
   386         shell.setBounds(x, y, newWidth, newHeight);
   377         //if (dispRect.width > dispRect.height)
       
   378         //{
       
   379         //    y /= 2;
       
   380         //}
       
   381         // Set bounds when command Buttons are in use.
       
   382         shell.setBounds(defShellBounds.x, y, defShellBounds.width, newHeight);
       
   383         Rectangle clientArea = shell.getClientArea();
   387         Rectangle clientArea = shell.getClientArea();
   384         iContainer.setSize(clientArea.width, clientArea.height);
   388         iContainer.setSize(clientArea.width, clientArea.height);
   385         iContainer.layout(true);
   389         iContainer.layout(true);
   386     }
   390     }
   387 
   391 
   556         {
   560         {
   557             size += aInstallInfo.getDataSize();
   561             size += aInstallInfo.getDataSize();
   558         }
   562         }
   559         if (size > 0)
   563         if (size > 0)
   560         {
   564         {
   561             createAppInfoLabel(
   565             if (size > 1024*1024)
   562                 InstallerUiTexts.get(
   566             {
   563                     InstallerUiTexts.SIZE_KB,
   567                 createAppInfoLabel(
   564                     new String[] { Long.toString(1 + size/1024) }));
   568                     InstallerUiTexts.get(
       
   569                         InstallerUiTexts.SIZE_MB,
       
   570                         new String[] { Long.toString(1 + size/(1024*1024)) }));
       
   571             }
       
   572             else
       
   573             {
       
   574                 createAppInfoLabel(
       
   575                     InstallerUiTexts.get(
       
   576                         InstallerUiTexts.SIZE_KB,
       
   577                         new String[] { Long.toString(1 + size/1024) }));
       
   578             }
   565         }
   579         }
   566         if (aFull)
   580         if (aFull)
   567         {
   581         {
   568             // Add application names.
   582             // Add application names.
   569             ApplicationInfo[] apps = aInstallInfo.getApplications();
   583             ApplicationInfo[] apps = aInstallInfo.getApplications();