guicomponents

## Class GCombo

- java.lang.Object
- - guicomponents.GComponent
  - - guicomponents.GCombo

- All Implemented Interfaces:
    GConstants, Comparable<Object>, PConstants

      public class GCombo
      extends GComponent

  Combo Box (drop down list) component.
  Author:
    Peter Lager

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class guicomponents.GComponent

      `GComponent.Z_Order`

  - ### Field Summary

    - ### Fields inherited from class guicomponents.GComponent

      `eventType, fGlobalFont, globalColor, globalColorScheme, globalFont, localColor, localFont, tag, tagNo, z`

    - ### Fields inherited from interface processing.core.PConstants

      `ADD, ALPHA, ALPHA_MASK, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_2D, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_STROKE_PERSPECTIVE, DISABLE_TEXTURE_CACHE, DISABLE_TEXTURE_MIPMAPS, DISABLE_TRANSFORM_CACHE, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ACCURATE_2D, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_STROKE_PERSPECTIVE, ENABLE_TEXTURE_CACHE, ENABLE_TEXTURE_MIPMAPS, ENABLE_TRANSFORM_CACHE, ENTER, EPSILON, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, GIF, GRAY, GREEN_MASK, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPHERE, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z`

    - ### Fields inherited from interface guicomponents.GConstants

      `ADD_DUPLICATE, BACKGROUND, CHANGED, CLICKED, CLOSE_WINDOW, COLLAPSED, CTRL_ANGULAR, CTRL_HORIZONTAL, CTRL_VERTICAL, DESELECTED, DISABLE_AUTO_DRAW, DRAGGED, ENTERED, EXCP_IN_HANDLER, EXIT_APP, EXPANDED, FAMILY, FOREGROUND, HUD_UNSUPPORTED, INVALID_STATUS, JUSTIFICATION, JUSTIFICATION_FULL, JUSTIFICATION_NONE, KEEP_OPEN, MISSING, NONEXISTANT, NOT_PEASYCAM, POSTURE, POSTURE_OBLIQUE, POSTURE_REGULAR, PRESSED, RELEASED, RUNTIME_ERROR, SCROLL_DOWN, SCROLL_LEFT, SCROLL_RIGHT, SCROLL_UP, SCROLLBAR_HORIZONTAL, SCROLLBAR_VERTICAL, SCROLLBARS_AUTOHIDE, SCROLLBARS_BOTH, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, SCROLLBARS_VERTICAL_ONLY, SELECTED, SET, SIZE, STRIKETHROUGH, STRIKETHROUGH_OFF, STRIKETHROUGH_ON, SUPERSCRIPT, SUPERSCRIPT_SUB, SUPERSCRIPT_SUPER, USER_COL_SCHEME, WEIGHT, WEIGHT_BOLD, WEIGHT_DEMIBOLD, WEIGHT_DEMILIGHT, WEIGHT_EXTRA_LIGHT, WEIGHT_EXTRABOLD, WEIGHT_HEAVY, WEIGHT_LIGHT, WEIGHT_MEDIUM, WEIGHT_REGULAR, WEIGHT_SEMIBOLD, WEIGHT_ULTRABOLD, WIDTH, WIDTH_CONDENSED, WIDTH_EXTENDED, WIDTH_REGULAR, WIDTH_SEMI_CONDENSED, WIDTH_SEMI_EXTENDED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GCombo(PApplet theApplet, String[] options, int maxRows, int x, int y, int width)` Create the combo using the string array for the options the first option in the list is made the selected one.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addOption(int pos, String optText)` Add an option in the given position
    `boolean` | `addOption(String optText)` Add an option to the end of the list
    `int` | `deselectedIndex()`
    `String` | `deselectedText()`
    `void` | `draw()` Draw the combo box
    `void` | `expand()` Open the drop down list
    `int` | `getNbrOptions()` Get the number of options
    `boolean` | `isExpanded()` Is the drop down list visible
    `boolean` | `isOver(int ax, int ay)` Determines whether the position ax, ay is over the expand arrow or over the expanded combo box, depending on whether the box is expanded or not.
    `void` | `loseFocus(GComponent grabber)` If we loose the focus to another GUI component that is not a child of this, then shrink the drop down list and release focus
    `GOption` | `makeOption(String optText)` Make a new option for the text optText
    `void` | `mouseEvent(MouseEvent event)` All GUI components are registered for mouseEvents
    `void` | `processOptionSelection(GOption sOpt, GOption dOpt)` This method is called when an option is selected from the drop down list.
    `void` | `processSliderMotion(GVertSlider vertslider)` INTERNAL USE ONLY This will handle the vertical slider events by changing the starting value of thefirst option to be shown.
    `void` | `removeAllOptions()` Removes all the current options from the combo box
    `void` | `removeOption(int index)` Remove an option based on its index value in the list
    `void` | `removeOption(String optText)` Remove a value based on its text value
    `int` | `selectedIndex()`
    `String` | `selectedText()`
    `void` | `setColorScheme(int schemeNo)` Sets the local color scheme
    `void` | `setFont(String fontname, int fontsize)` Set the font & size for the combo changing height and width of the button if necessary to display text.
    `void` | `setOptions(String[] optTexts, int selected)` This will replace all options with the new options specified.
    `void` | `setSelected(int index)` Set the selected option by its index value.
    `void` | `setSelected(String optText)` Set the selected option by its text value
    `void` | `shrink()` Close the drop down list
    `String` | `toString()`

    - ### Methods inherited from class guicomponents.GComponent

      `add, addAbsoluteControl, addCompoundControl, addEventHandler, addEventHandler, addRelativeControl, addXXX, calcAbsPosition, changeWindow, compareTo, contains, ctrlMode, dispose, getAlpha, getBorder, getCtrlMode, getEventType, getFocusObject, getHeight, getOpaque, getPApplet, getParent, getStyledText, getText, getTransform, getWidth, getX, getY, hasFocus, hasKeyFocus, isEnabled, isVisible, keyPressed, pre, remove, setAlpha, setBorder, setEnabled, setFocus, setFontNew, setFontNew, setHeight, setLocalColorScheme, setOpaque, setRotation, setText, setText, setTextAlign, setTextNew, setTextNew, setVisible, setWidth, setX, setXY, setY`

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

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

- - ### Constructor Detail

    - #### GCombo

          public GCombo(PApplet theApplet,
                String[] options,
                int maxRows,
                int x,
                int y,
                int width)

      Create the combo using the string array for the options the first option in the list is made the selected one. If you want another then use setSelected()
      Parameters:
        `theApplet` -
        `options` -
        `maxRows` -
        `x` -
        `y` -
        `width` -

  - ### Method Detail

    - #### makeOption

          public GOption makeOption(String optText)

      Make a new option for the text optText
      Parameters:
        `optText` - the text to appear on the option.
      Returns:
        reference to option created and added else null

    - #### setFont

          public void setFont(String fontname,
                     int fontsize)

      Set the font & size for the combo changing height and width of the button if necessary to display text.
      It will not shrink if the font size is decreased.
      Overrides:
        `setFont` in class `GComponent`

    - #### setColorScheme

          public void setColorScheme(int schemeNo)

      Sets the local color scheme
      Overrides:
        `setColorScheme` in class `GComponent`
      Parameters:
        `schemeNo` -

    - #### processSliderMotion

          public void processSliderMotion(GVertSlider vertslider)

      INTERNAL USE ONLY
      This will handle the vertical slider events by changing the starting value of thefirst option to be shown.
      Parameters:
        `vertslider` -

    - #### processOptionSelection

          public void processOptionSelection(GOption sOpt,
                                    GOption dOpt)

      This method is called when an option is selected from the drop down list.
      Parameters:
        `sOpt` - selected option
        `dOpt` - deselected option

    - #### setSelected

          public void setSelected(int index)

      Set the selected option by its index value. (Starts at 0)
      Parameters:
        `index` -

    - #### setSelected

          public void setSelected(String optText)

      Set the selected option by its text value
      Parameters:
        `optText` -

    - #### addOption

          public boolean addOption(String optText)

      Add an option to the end of the list
      Parameters:
        `optText` -
      Returns:
        true if option successfully added

    - #### addOption

          public boolean addOption(int pos,
                          String optText)

      Add an option in the given position
      Parameters:
        `pos` -
        `optText` -
      Returns:
        true if option successfully added

    - #### removeOption

          public void removeOption(int index)

      Remove an option based on its index value in the list
      Parameters:
        `index` -

    - #### removeOption

          public void removeOption(String optText)

      Remove a value based on its text value
      Parameters:
        `optText` -

    - #### getNbrOptions

          public int getNbrOptions()

      Get the number of options
      Returns:

    - #### removeAllOptions

          public void removeAllOptions()

      Removes all the current options from the combo box

    - #### setOptions

          public void setOptions(String[] optTexts,
                        int selected)

      This will replace all options with the new options specified.
      Parameters:
        `optTexts` - the new options
        `selected` - the initial selection (uses 0 if invalid)

    - #### isOver

          public boolean isOver(int ax,
                       int ay)

      Determines whether the position ax, ay is over the expand arrow or over the expanded combo box, depending on whether the box is expanded or not.
      Overrides:
        `isOver` in class `GComponent`
      Parameters:
        `ax` - mouse x position
        `ay` - mouse y position
      Returns:
        true if mouse is over the appropriate part

    - #### shrink

          public void shrink()

      Close the drop down list

    - #### expand

          public void expand()

      Open the drop down list

    - #### isExpanded

          public boolean isExpanded()

      Is the drop down list visible
      Returns:
        true if the combo list is visible (ie down) else false

    - #### loseFocus

          public void loseFocus(GComponent grabber)

      If we loose the focus to another GUI component that is not a child of this, then shrink the drop down list and release focus

    - #### mouseEvent

          public void mouseEvent(MouseEvent event)

      All GUI components are registered for mouseEvents
      Overrides:
        `mouseEvent` in class `GComponent`

    - #### draw

          public void draw()

      Draw the combo box
      Overrides:
        `draw` in class `GComponent`

    - #### selectedIndex

          public int selectedIndex()

    - #### selectedText

          public String selectedText()

    - #### deselectedIndex

          public int deselectedIndex()

    - #### deselectedText

          public String deselectedText()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `GComponent`

Processing library guicomponents by Peter Lager. (C) 2012