org.vishia.gral.awt

## Class AwtWidgetMng

- java.lang.Object
- - org.vishia.gral.base.GralMng.ImplAccess
  - - org.vishia.gral.awt.AwtWidgetMng

-     public class AwtWidgetMng
      extends GralMng.ImplAccess

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `AwtWidgetMng.AwtMngFocusListener` Universal focus listener to register which widgets were in focus in its order, to set htmlHelp and to invoke the `GralWidget.setActionFocused(GralUserAction)`.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AwtWidgetMng.AwtMngFocusListener` | `focusListener` The package private universal focus listener.
    `(package private) AwtGralMouseListener.MouseListenerGralAction` | `mouseStdAction` The standard listener or action for mouse events, able to assign to all widgets which does not need an extra mouse behaviour.
    `(package private) AwtProperties` | `propertiesGuiAwt`
    `(package private) java.awt.event.KeyListener` | `XXXXX_mainKeyListener`

    - ### Fields inherited from class org.vishia.gral.base.GralMng.ImplAccess

      `mng`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AwtWidgetMng(AwtProperties propertiesGui, LogMessage log)` Creates an instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(GralTable<?> table)`
    `GralCurveView` | `addCurveViewY(java.lang.String sName, int nrofXvalues, GralCurveView.CommonCurve common)`
    `void` | `addFocusAction(GralWidget widgetInfo, GralUserAction action, java.lang.String sCmdEnter, java.lang.String sCmdRelease)`
    `GralWidget` | `addFocusAction(java.lang.String sName, GralUserAction action, java.lang.String sCmdEnter, java.lang.String sCmdRelease)`
    `GralHtmlBox` | `addHtmlBox(java.lang.String name)` Adds a text box for showing or editing a text in multi lines.
    `java.lang.Object` | `addImage(java.lang.String sName, java.io.InputStream imageStream, int height, int width, java.lang.String sCmd)`
    `GralWidget` | `addSlider(java.lang.String sName, GralUserAction action, java.lang.String sShowMethod, java.lang.String sDataPath)`
    `GralTabbedPanel` | `addTabbedPanel(java.lang.String namePanel, GralPanelActivated_ifc user, int properties)`
    `GralTable` | `addTable(java.lang.String sName, int height, int[] columnWidths)`
    `GralWidget` | `addText(java.lang.String sText, char size, int color)` Deprecated.
    `(package private) GralRectangle` | `calcPositionOfWindow(GralPos posWindow)` Calculates the position as absolute value on screen from a given position inside a panel.
    `GralRectangle` | `calcWidgetPosAndSize(GralPos pos, int widthwidgetNat, int heigthWidgetNat)` Calculates the bounds of a widget with a given pos independent of this `GralMng.ImplAccess.pos()`.
    `(package private) GralRectangle` | `calcWidgetPosAndSizeAwt(GralPos pos, java.awt.Component component, int widthwidgetNat, int heigthWidgetNat)` Calculates the bounds of a SWT component with a given position independent of `GralMng.ImplAccess.pos()`.
    `GralPanelContent` | `createCompositeBox(java.lang.String name)` Creates a box inside the current panel to hold some widgets.
    `protected GralMenu` | `createContextMenu(GralWidget widg)` Creates the context menu for the given widget for right-mouse pressing.
    `GralFileDialog_ifc` | `createFileDialog()`
    `GralPanelContent` | `createGridPanel(java.lang.String namePanel, GralColor backGround, int xG, int yG, int xS, int yS)` Creates an independent grid panel which is managed by this.
    `void` | `createImplWidget_Gthread(GralWidget widgg)`
    `protected GralMenu` | `createMenuBar(GralWindow windg)` Creates the menu bar for the given window.
    `void` | `createSubWindow(GralWindow windowGral)`
    `GralWindow` | `createWindow(java.lang.String name, java.lang.String title, int windPros)`
    `java.awt.Color` | `getColorImpl(GralColor color)` Gets the color of the graphic implementation (swt.Color, swing.TODO) Either the implementation color instance is stored already in the GralColor, or it will be created, stored in GralColor and returned here.
    `java.awt.Container` | `getCurrentPanel()`
    `(package private) GralRectangle` | `getPixelUseableAreaOfWindow(GralWidget widgg)`
    `java.lang.String` | `getValueFromWidget(GralWidget widgetDescr)`
    `java.awt.Container` | `getWidgetsPanel(GralWidget widg)`
    `void` | `redrawWidget(java.lang.String sName)` Forces the redrawing for all set samples.
    `boolean` | `remove(GralPanelContent compositeBox)`
    `void` | `resizeWidget(GralWidget widgd, int xSizeParent, int ySizeParent)` Forces the resizing of the given widged.
    `(package private) void` | `setBounds_(GralPos pos, java.awt.Component component)` Places a current component with knowledge of the current positions and the spreads of the component on graphic.
    `protected void` | `setPosAndSize_(GralPos pos, java.awt.Component component)`
    `(package private) void` | `setPosAndSizeAwt(GralPos posP, java.awt.Component component, int widthwidgetNat, int heigthWidgetNat)` Set bounds of a AWT component with a given position.
    `void` | `setSampleCurveViewY(java.lang.String sName, float[] values)` Adds a sampling value set.
    `boolean` | `showContextMenuGthread(GralWidget widg)` Shows the context menu of any widget independent of the internal right-mouse invocation.
    `(package private) void` | `stop()`
    `protected GralMenu` | `XXXaddPopupMenu(java.lang.String sName)`
    `protected void` | `XXXsetPosAndSize_(java.awt.Component component, int widthwidgetNat, int heigthWidgetNat)`
    `boolean` | `XXXsetWindowsVisible(GralWindow_ifc window, GralPos atPos)` Sets a given and registered window visible at the given position and size or set it invisible.

    - ### Methods inherited from class org.vishia.gral.base.GralMng.ImplAccess

      `indexNameWidgets, listVisiblePanels_add, pos, sCurrPanel, userMainKeyAction`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### propertiesGuiAwt

          final AwtProperties propertiesGuiAwt

    - #### mouseStdAction

          final AwtGralMouseListener.MouseListenerGralAction mouseStdAction

      The standard listener or action for mouse events, able to assign to all widgets which does not need an extra mouse behaviour.

    - #### XXXXX_mainKeyListener

          java.awt.event.KeyListener XXXXX_mainKeyListener

    - #### focusListener

          protected AwtWidgetMng.AwtMngFocusListener focusListener

      The package private universal focus listener.

  - ### Constructor Detail

    - #### AwtWidgetMng

          public AwtWidgetMng(AwtProperties propertiesGui,
                              LogMessage log)

      Creates an instance.
      Parameters:
        `guiContainer` - The container where the elements are stored in.
        `width` - in display-units for the window's width, the number of pixel depends from param displaySize.
        `height` - in display-units for the window's height, the number of pixel depends from param displaySize.
        `displaySize` - character 'A' to 'E' to determine the size of the content (font size, pixel per cell). 'A' is the smallest, 'E' the largest size. Default: use 'C'.

  - ### Method Detail

    - #### getCurrentPanel

          public java.awt.Container getCurrentPanel()

      Specified by:
        `getCurrentPanel` in class `GralMng.ImplAccess`

    - #### getWidgetsPanel

          public java.awt.Container getWidgetsPanel(GralWidget widg)

    - #### createImplWidget_Gthread

          public void createImplWidget_Gthread(GralWidget widgg)

      Specified by:
        `createImplWidget_Gthread` in class `GralMng.ImplAccess`

    - #### addHtmlBox

          public GralHtmlBox addHtmlBox(java.lang.String name)

      Adds a text box for showing or editing a text in multi lines.
      Specified by:
        `addHtmlBox` in class `GralMng.ImplAccess`
      Parameters:
        `sName` - The registering name
        `width` - Number of grid units for length
        `editable` - true than edit-able, false to show content
        `prompt` - If not null, than a description label is shown
        `promptStylePosition` - Position and size of description label: upper case letter: normal font, lower case letter: small font 'l' left, 't' top (above field)
      Returns:
        //@Override public GralTextBox addTextBox(String name, boolean editable, String prompt, char promptStylePosition) { Container parent = (Container)pos().panel.getWidgetImplementation(); AwtTextBox widgetSwt = new AwtTextBox(name, parent, 0, this); GralWidget widgetInfo = widgetSwt; widgetInfo.setPanelMng(mng); //Text widgetSwt = new Text(((PanelSwt)pos.panel).getPanelImpl(), SWT.MULTI); widgetSwt.textFieldSwt.setFont(propertiesGuiAwt.stdInputFont); widgetSwt.textFieldSwt.setEditable(editable); if(editable) stop(); widgetSwt.textFieldSwt.setBackground(propertiesGuiAwt.colorAwt(GralColor.getColor("pbl"))); //widgetSwt.textFieldSwt.addMouseListener(mouseClickForInfo); setPosAndSize_(widgetSwt.textFieldSwt); if(prompt != null && promptStylePosition == 't'){ final int yPixelField; final Font promptFont; int ySize = (int)(pos().height()); switch(ySize){ case 3: promptFont = propertiesGuiAwt.smallPromptFont; yPixelField = propertiesGuiAwt.yPixelUnit() * 2 -3; break; case 2: promptFont = propertiesGuiAwt.smallPromptFont; yPixelField = (int)(1.5F * mng.propertiesGui.yPixelUnit()); break; default: promptFont = propertiesGuiAwt.smallPromptFont; yPixelField = mng.propertiesGui.yPixelUnit() * 2 -3; }//switch Rectangle boundsField = widgetSwt.textFieldSwt.getBounds(); Rectangle boundsPrompt = new Rectangle(boundsField.x, boundsField.y-3 //occupy part of field above, only above the normal letters , boundsField.width, boundsField.height ); if(promptStylePosition == 't'){ boundsPrompt.height -= (yPixelField -4); boundsPrompt.y -= 1; boundsField.y += (boundsField.height - yPixelField ); boundsField.height = yPixelField; } Label wgPrompt = new Label(); parent.add(wgPrompt); wgPrompt.setFont(promptFont); wgPrompt.setText(prompt); widgetSwt.textFieldSwt.setBounds(boundsField); wgPrompt.setBounds(boundsPrompt); } // if(widgetInfo.name !=null && widgetInfo.name.charAt(0) == '$'){ widgetInfo.name = sCurrPanel() + widgetInfo.name.substring(1); } //link the widget with is information together. widgetSwt.textFieldSwt.setData(widgetInfo); if(widgetInfo.name !=null){ if(!editable){ mng.registerShowField(widgetInfo); } } mng.registerWidget(widgetInfo); return widgetSwt; }

    - #### addCurveViewY

          public GralCurveView addCurveViewY(java.lang.String sName,
                                             int nrofXvalues,
                                             GralCurveView.CommonCurve common)

      Specified by:
        `addCurveViewY` in class `GralMng.ImplAccess`

    - #### addFocusAction

          public GralWidget addFocusAction(java.lang.String sName,
                                           GralUserAction action,
                                           java.lang.String sCmdEnter,
                                           java.lang.String sCmdRelease)

      Specified by:
        `addFocusAction` in class `GralMng.ImplAccess`

    - #### addFocusAction

          public void addFocusAction(GralWidget widgetInfo,
                                     GralUserAction action,
                                     java.lang.String sCmdEnter,
                                     java.lang.String sCmdRelease)

      Specified by:
        `addFocusAction` in class `GralMng.ImplAccess`

    - #### addImage

          public java.lang.Object addImage(java.lang.String sName,
                                           java.io.InputStream imageStream,
                                           int height,
                                           int width,
                                           java.lang.String sCmd)

      Specified by:
        `addImage` in class `GralMng.ImplAccess`

    - #### addSlider

          public GralWidget addSlider(java.lang.String sName,
                                      GralUserAction action,
                                      java.lang.String sShowMethod,
                                      java.lang.String sDataPath)

      Specified by:
        `addSlider` in class `GralMng.ImplAccess`

    - #### addTable

          public GralTable addTable(java.lang.String sName,
                                    int height,
                                    int[] columnWidths)

      Specified by:
        `addTable` in class `GralMng.ImplAccess`

    - #### add

          public void add(GralTable<?> table)

    - #### addText

          @Deprecated
          public GralWidget addText(java.lang.String sText,
                                                 char size,
                                                 int color)

      Deprecated.
      Specified by:
        `addText` in class `GralMng.ImplAccess`

    - #### XXXaddPopupMenu

          protected GralMenu XXXaddPopupMenu(java.lang.String sName)

      Specified by:
        `XXXaddPopupMenu` in class `GralMng.ImplAccess`

    - #### createContextMenu

          protected GralMenu createContextMenu(GralWidget widg)

      Description copied from class: `GralMng.ImplAccess`
      Creates the context menu for the given widget for right-mouse pressing. This method is invoked only in `GralWidget.getContextMenu()` whereby an existing context menu is stored in the `GralWidget.contextMenu` association. The widget have to be set to panel already, an implementation widget have to be existing. It means `GralWidget#getWidgetImplementation()` should be return that instance where the menu is to be added. This method is package protected because it should only be called internally.
      Specified by:
        `createContextMenu` in class `GralMng.ImplAccess`

    - #### createMenuBar

          protected GralMenu createMenuBar(GralWindow windg)

      Description copied from class: `GralMng.ImplAccess`
      Creates the menu bar for the given window. This method is invoked only in `GralWindow.getMenuBar()` whereby an existing menu bar is stored in the `GralWindow.menuBarGral` association.
      Specified by:
        `createMenuBar` in class `GralMng.ImplAccess`
      Parameters:
        `windg` - The window

    - #### createCompositeBox

          public GralPanelContent createCompositeBox(java.lang.String name)

      Description copied from class: `GralMng.ImplAccess`
      Creates a box inside the current panel to hold some widgets.
      Specified by:
        `createCompositeBox` in class `GralMng.ImplAccess`
      Returns:

    - #### createFileDialog

          public GralFileDialog_ifc createFileDialog()

      Specified by:
        `createFileDialog` in class `GralMng.ImplAccess`

    - #### createGridPanel

          public GralPanelContent createGridPanel(java.lang.String namePanel,
                                                  GralColor backGround,
                                                  int xG,
                                                  int yG,
                                                  int xS,
                                                  int yS)

      Description copied from class: `GralMng.ImplAccess`
      Creates an independent grid panel which is managed by this. The panel can be associated to any graphic frame.
      Specified by:
        `createGridPanel` in class `GralMng.ImplAccess`
      Returns:

    - #### addTabbedPanel

          public GralTabbedPanel addTabbedPanel(java.lang.String namePanel,
                                                GralPanelActivated_ifc user,
                                                int properties)

      Specified by:
        `addTabbedPanel` in class `GralMng.ImplAccess`

    - #### createWindow

          public GralWindow createWindow(java.lang.String name,
                                         java.lang.String title,
                                         int windPros)

      Specified by:
        `createWindow` in class `GralMng.ImplAccess`

    - #### createSubWindow

          public void createSubWindow(GralWindow windowGral)

      Specified by:
        `createSubWindow` in class `GralMng.ImplAccess`

    - #### calcPositionOfWindow

          GralRectangle calcPositionOfWindow(GralPos posWindow)

      Calculates the position as absolute value on screen from a given position inside a panel.
      Parameters:
        `posWindow` - contains any `GralPos.panel`. Its absolute position will be determined. from that position and size the absolute postion will be calculate, with this given grid positions inside the panel.
      Returns:
        Absolute pixel coordinate.

    - #### getPixelUseableAreaOfWindow

          GralRectangle getPixelUseableAreaOfWindow(GralWidget widgg)

    - #### remove

          public boolean remove(GralPanelContent compositeBox)

      Specified by:
        `remove` in class `GralMng.ImplAccess`

    - #### getColorImpl

          public java.awt.Color getColorImpl(GralColor color)

      Description copied from class: `GralMng.ImplAccess`
      Gets the color of the graphic implementation (swt.Color, swing.TODO) Either the implementation color instance is stored already in the GralColor, or it will be created, stored in GralColor and returned here.
      Specified by:
        `getColorImpl` in class `GralMng.ImplAccess`
      Parameters:
        `color` - The Color.
      Returns:
        Instance of the implementation color.

    - #### getValueFromWidget

          public java.lang.String getValueFromWidget(GralWidget widgetDescr)

      Specified by:
        `getValueFromWidget` in class `GralMng.ImplAccess`

    - #### redrawWidget

          public void redrawWidget(java.lang.String sName)

      Description copied from class: `GralMng.ImplAccess`
      Forces the redrawing for all set samples. It should be called after { @link #setSampleCurveViewY(String, float[])}.
      Specified by:
        `redrawWidget` in class `GralMng.ImplAccess`
      Parameters:
        `sName` - The name of the widget.

    - #### resizeWidget

          public void resizeWidget(GralWidget widgd,
                                   int xSizeParent,
                                   int ySizeParent)

      Description copied from class: `GralMng.ImplAccess`
      Forces the resizing of the given widged.
      Specified by:
        `resizeWidget` in class `GralMng.ImplAccess`
      Parameters:
        `widgd` - the widget

    - #### setSampleCurveViewY

          public void setSampleCurveViewY(java.lang.String sName,
                                          float[] values)

      Description copied from class: `GralMng.ImplAccess`
      Adds a sampling value set.
      Specified by:
        `setSampleCurveViewY` in class `GralMng.ImplAccess`
      Parameters:
        `sName` - The registered name
        `values` - The values.

    - #### setBounds_

          void setBounds_(GralPos pos,
                          java.awt.Component component)

      Places a current component with knowledge of the current positions and the spreads of the component on graphic.
      Parameters:
        `component` - The component to place.

    - #### setPosAndSize_

          protected void setPosAndSize_(GralPos pos,
                                        java.awt.Component component)

    - #### XXXsetPosAndSize_

          protected void XXXsetPosAndSize_(java.awt.Component component,
                                           int widthwidgetNat,
                                           int heigthWidgetNat)

      Parameters:
        `component` -
        `widthwidgetNat` -
        `heigthWidgetNat` - NOTE: 2015-07-13: This method is set to unused because it uses the mng-position additional to the constructor of GralWidget. This is the old concept which is in conflict with the usuage there.

    - #### setPosAndSizeAwt

          void setPosAndSizeAwt(GralPos posP,
                                java.awt.Component component,
                                int widthwidgetNat,
                                int heigthWidgetNat)

      Set bounds of a AWT component with a given position. This method is package-private for SWT-implementation.
      Parameters:
        `posP` - The Position for the component.
        `component` - The AWT-widget.
        `widthwidgetNat` - The natural size of the component.
        `heigthWidgetNat` - The natural size of the component.

    - #### calcWidgetPosAndSize

          public GralRectangle calcWidgetPosAndSize(GralPos pos,
                                                    int widthwidgetNat,
                                                    int heigthWidgetNat)

      Calculates the bounds of a widget with a given pos independent of this `GralMng.ImplAccess.pos()`. This method is a part of the implementing GralMng because the GralPos is not implemented for any underlying graphic system and the `#propertiesGuiSwt` are used. It is possible to tune the bounds after calculation, for example to enhance the width if a text is larger then the intended position.
      Specified by:
        `calcWidgetPosAndSize` in class `GralMng.ImplAccess`
      Parameters:
        `pos` - The position.
        `widthwidgetNat` - The natural size of the component.
        `heigthWidgetNat` - The natural size of the component.
      Returns:
        A rectangle with position and size.

    - #### calcWidgetPosAndSizeAwt

          GralRectangle calcWidgetPosAndSizeAwt(GralPos pos,
                                                java.awt.Component component,
                                                int widthwidgetNat,
                                                int heigthWidgetNat)

      Calculates the bounds of a SWT component with a given position independent of `GralMng.ImplAccess.pos()`. This method is package-private for SWT-implementation. It is possible to tune the bounds after calculation, for example to enhance the width if a text is larger then the intended position.
      Parameters:
        `pos` - The position.
        `component` - The SWT-widget.
        `widthwidgetNat` - The natural size of the component.
        `heigthWidgetNat` - The natural size of the component.
      Returns:
        A rectangle with position and size.

    - #### showContextMenuGthread

          public boolean showContextMenuGthread(GralWidget widg)

      Description copied from class: `GralMng.ImplAccess`
      Shows the context menu of any widget independent of the internal right-mouse invocation.
      Specified by:
        `showContextMenuGthread` in class `GralMng.ImplAccess`
      Parameters:
        `widg` - The widget.
      Returns:
        true if the widget have a context menu.

    - #### stop

          void stop()

    - #### XXXsetWindowsVisible

          public boolean XXXsetWindowsVisible(GralWindow_ifc window,
                                              GralPos atPos)

      Description copied from class: `GralMng.ImplAccess`
      Sets a given and registered window visible at the given position and size or set it invisible.
      A window can be created by invoking `org.vishia.gral.ifc.GralMngBuild_ifc#createWindow(String, boolean)` in the build phase of the gui. It can be hidden because it is not necessary to show and operate with them. In a adequate phase of operate it can be shown and focused.
      The position is given relative to that panel, which is stored in `GralPos.panel`. To get a position instance, you can set a position invoking
      - `GralMngBuild_ifc.selectPanel(String)`
      - `GralMngBuild_ifc.setPosition(float, float, float, float, int, char)`
      - GralGridPos pos = `GralMngBuild_ifc.getPositionInPanel()`.
      That can be done in the build phase of the graphic. The position can be stored. It is possible to adjust the position relative to the unchanged panel by changing the values of `GralPos.x` etc. It is possible too to change the Panel which relates to the position. Then the grid managing instance have to be known via the `GralMngBuild_ifc` to select a panel. The panels may be moved or resized. With the knowledge of the relative position of the window in respect to a panel of the parent window, the window can be placed onto a proper position of the whole display.
      Specified by:
        `XXXsetWindowsVisible` in class `GralMng.ImplAccess`
      Parameters:
        `window` - the instance of the window wrapper.
        `atPos` - If null then hide the window. If not null then show the window. The position and size of the window is given related to any panel of any other window.
      Returns:
        true if it is visible.