org.vishia.gral.widget

## Class GralHorizontalSelector<UserData>

- java.lang.Object
- - org.vishia.gral.base.GralWidget
  - - org.vishia.gral.widget.GralHorizontalSelector<UserData>

- All Implemented Interfaces:
    GetGralWidget_ifc, GralSetValue_ifc, GralWidget_ifc, Removeable

      public class GralHorizontalSelector<UserData>
      extends GralWidget

  This widget is a selector with tabs. It can be placed like a text field. Selecting a tab the `GralWidget.setActionChange(GralUserAction)` is called with the associated UserData of the tab is third parameter of `GralUserAction.exec(int, GralWidget_ifc, Object...)` with `KeyCode.activated`. That can focus, show or select some widgets, panels etc. With them a tab-panel is able to build, but in a more possibilities than usual implementations of such tab-panels.
  The tabs are shift to left and right if the spaces is to less.
  Tabs can be closed with right-mouse context menu. Then the `GralUserAction.exec(int, GralWidget_ifc, Object...)` will be called a last time for the barely known UserData the last time with `KeyCode.removed`. If the current selected tab will be removed, the tab left of them or the next if it was the first will be activated with calling of `GralUserAction.exec(int, GralWidget_ifc, Object...)` for the yet current selected tab if there is any one yet.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `GralHorizontalSelector.GraphicImplAccess<UserData>` This class is not intent to use from an application, it is the super class for the implementation layer to access all necessary data and methods with protected access rights.
    `static class` | `GralHorizontalSelector.Item<UserData>`

    - ### Nested classes/interfaces inherited from class org.vishia.gral.base.GralWidget

      `GralWidget.ActionChangeSelect, GralWidget.ConfigData, GralWidget.DynamicData, GralWidget.ImplAccess`

    - ### Nested classes/interfaces inherited from interface org.vishia.gral.ifc.GralWidget_ifc

      `GralWidget_ifc.ActionChange, GralWidget_ifc.ActionChangeWhen`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) GralUserAction` | `actionRemoveTab`
    `protected GralHorizontalSelector.Item<UserData>` | `actItem`
    `GralColor` | `colorBack`
    `GralColor` | `colorLine`
    `GralColor` | `colorSelect`
    `GralColor` | `colorText`
    `protected java.util.List<GralHorizontalSelector.Item<UserData>>` | `items`
    `protected int` | `ixActItem` The item (index in `items` which is the current or actual used one.
    `protected int` | `ixDstItem` The item which is selected while the mouse button is pressed and hold, not released yet.
    `protected int` | `ixLeftItem` The item which is shown as left in the graphic.
    `protected int` | `minSize`
    `static int` | `version` Version, history and copyright/copyleft.

    - ### Fields inherited from class org.vishia.gral.base.GralWidget

      `_wdgImpl, bEditable, bHasFocus, bShouldInitialize, buildMng, bVisibleState, cfg, contextMenu, dateUser, dyda, htmlHelp, itsMng, name, repaintDelay, repaintDelayMax, sCmd, sFormat, sToolTip, sVersion, whatIs`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GralHorizontalSelector(java.lang.String name, GralUserAction actionOnSelect)` The constructor creates the instance but does nothing with the graphic appearance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addItem(java.lang.String text, int position, UserData data)` Adds a item to show.
    `void` | `removeItem(java.lang.String text)` Remove a item.
    `protected void` | `removeTab()` Called on mouse action in context menu.
    `boolean` | `setActItem(java.lang.String name)`
    `protected void` | `setDstToActItem()`

    - ### Methods inherited from class org.vishia.gral.base.GralWidget

      `chgPos, clearShowParam, createImplWidget_Gthread, getActionChange, getActionChangeStrict, getActionDrag, getActionDrop, getActionFocused, getActionShow, getBackColor, getCfgElement, getCmd, getCmd, getContentIdent, getContentInfo, getContextMenu, getData, getDataIx, getDataPath, getDataPath, getFloatValue, getFormat, getGralWidget, getHtmlHelp, getImpl, getItsPanel, getLongValue, getName, getShowMethod, getShowParam, getsToolTip, getText, getValue, getVariable, getVariableFromContentInfo, gralMng, isChanged, isEditable, isGraphicDisposed, isInFocus, isNotEditableOrShouldInitialize, isVisible, pos, refreshFromVariable, refreshFromVariable, remove, repaint, repaint, requestNewValueForVariable, setActionChange, setActionFocused, setActionMouse, setActionShow, setBackColor, setBackgroundColor, setBoundsPixel, setCfgElement, setCmd, setContentIdent, setContentInfo, setData, setDataIx, setDataPath, setDragEnable, setDropEnable, setEditable, setFocus, setFocus, setForegroundColor, setFormat, setHtmlHelp, setLineColor, setLongValue, setMinMax, setPanelMng, setPrimaryWidgetOfPanel, setText, setTextColor, setToolTip, setToPanel, setValue, setValue, setValue, setValue, setVisible, setVisibleState, setVisibleStateWidget, specifyActionChange, specifyContextMenu, toString, XXXgetPixelPositionSize, XXXgetWidgetImplementation, XXXremoveWidgetImplementation, XXXrepaintGthread, XXXsetFocusGThread, XXXsetVisibleGThread`

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

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

- - ### Field Detail

    - #### version

          public static final int version

      Version, history and copyright/copyleft.
      - 2013-06-18 Hartmut created, new idea.
      Copyright/Copyleft:
      For this source the LGPL Lesser General Public License, published by the Free Software Foundation is valid. It means:
      1. You can use this source without any restriction for any desired purpose.
      2. You can redistribute copies of this source to everybody.
      3. Every user of this source, also the user of redistribute copies with or without payment, must accept this license for further using.
      4. But the LPGL is not appropriate for a whole software product, if this source is only a part of them. It means, the user must publish this part of source, but doesn't need to publish the whole source of the own product.
      5. You can study and modify (improve) this source for own using or for redistribution, but you have to license the modified sources likewise under this LGPL Lesser General Public License. You mustn't delete this Copyright/Copyleft inscription in this source file.
      If you intent to use this source without publishing its usage, you can get a second license subscribing a special contract with the author.
      See Also:
        Constant Field Values

    - #### items

          protected java.util.List<GralHorizontalSelector.Item<UserData>> items

    - #### actItem

          protected GralHorizontalSelector.Item<UserData> actItem

    - #### ixActItem

          protected int ixActItem

      The item (index in `items` which is the current or actual used one.

    - #### ixDstItem

          protected int ixDstItem

      The item which is selected while the mouse button is pressed and hold, not released yet.

    - #### ixLeftItem

          protected int ixLeftItem

      The item which is shown as left in the graphic.

    - #### minSize

          protected int minSize

    - #### colorText

          public GralColor colorText

    - #### colorSelect

          public GralColor colorSelect

    - #### colorBack

          public GralColor colorBack

    - #### colorLine

          public GralColor colorLine

    - #### actionRemoveTab

          GralUserAction actionRemoveTab

  - ### Constructor Detail

    - #### GralHorizontalSelector

          public GralHorizontalSelector(java.lang.String name,
                                        GralUserAction actionOnSelect)

      The constructor creates the instance but does nothing with the graphic appearance.
      Parameters:
        `name` -
        `mng` -

  - ### Method Detail

    - #### addItem

          public void addItem(java.lang.String text,
                              int position,
                              UserData data)

      Adds a item to show.
      Parameters:
        `text` -
        `position` -
        `data` -

    - #### setActItem

          public boolean setActItem(java.lang.String name)

    - #### removeItem

          public void removeItem(java.lang.String text)

      Remove a item.
      Parameters:
        `text` -

    - #### setDstToActItem

          protected void setDstToActItem()

    - #### removeTab

          protected void removeTab()

      Called on mouse action in context menu.