guicomponents

## Class GImageButton

- java.lang.Object
- - guicomponents.GComponent
  - - guicomponents.GImageButton

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

      public class GImageButton
      extends GComponent

  Buttons create from this class use a number of images to represent it's state. This means that buttons can have an irregular and/or discontinuous shape.
  The image button needs 1 to 3 image files to represent the button states
  OFF mouse is not over button
  OVER mouse is over the button
  DOWN the mouse is over the button and a mouse button is being pressed.
  If you only provide one image then this will be used for all states, if you provide two then the second image is used for both OVER and DOWN states.
  Rather than separate files for the different image states you can provide a single image file which is a composite of 1-3 images (tiled horizontally) which are used for the different button states OFF, OVER and DOWN
  If you don't provide a mask file then the button 'hotspot' is represented by any non-transparent pixels in the OFF image. If you do provide a mask file then the hotspot is defined by any white pixels in the mask image.
  Three types of event can be generated :-
  PRESSED RELEASED CLICKED
  To simplify event handling the button only fires off CLICKED events if the mouse button is pressed and released over the button face (the default behaviour).
  Using

      button1.fireAllEvents(true);

  enables the other 2 events for button button1. A PRESSED event is created if the mouse button is pressed down over the button face, the CLICKED event is then generated if the mouse button is released over the button face. Releasing the button off the button face creates a RELEASED event.
  Author:
    Peter Lager

- - ### Nested Class Summary

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

      `GComponent.Z_Order`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DOWN`
    `static int` | `OFF`
    `static int` | `OVER`

    - ### 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, 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
    `GImageButton(PApplet theApplet, String maskFile, String[] imgFiles, int x, int y)`
    `GImageButton(PApplet theApplet, String maskFile, String imgFile, int nbrImages, int x, int y)` Create an image button based on a composite image for the button states.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `draw()` Draw the button
    `void` | `fireAllEvents(boolean all)` If the parameter is true all 3 event types are generated, if false only CLICKED events are generated (default behaviour).
    `boolean` | `isOver(int ax, int ay)` Determines whether the position ax, ay is over this component.
    `void` | `mouseEvent(MouseEvent event)` All GUI components are registered for mouseEvents.

    - ### 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, setColorScheme, setEnabled, setFocus, setFont, setFontNew, setFontNew, setHeight, setLocalColorScheme, setOpaque, setRotation, setText, setText, setTextAlign, setTextNew, setTextNew, setVisible, setWidth, setX, setXY, setY, toString`

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

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

- - ### Field Detail

    - #### OFF

          public static final int OFF

      See Also:
        Constant Field Values

    - #### OVER

          public static final int OVER

      See Also:
        Constant Field Values

    - #### DOWN

          public static final int DOWN

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### GImageButton

          public GImageButton(PApplet theApplet,
                      String maskFile,
                      String imgFile,
                      int nbrImages,
                      int x,
                      int y)

      Create an image button based on a composite image for the button states.
      Parameters:
        `theApplet` -
        `maskFile` - null if none is to be provided
        `imgFile` - composite image file for button sates
        `nbrImages` - number of images in composite image
        `x` - top-left horizontal distance for the buttun
        `y` - top left vertical position for the buttun

    - #### GImageButton

          public GImageButton(PApplet theApplet,
                      String maskFile,
                      String[] imgFiles,
                      int x,
                      int y)

      Parameters:
        `theApplet` -
        `maskFile` - null if none is to be provided
        `imgFiles` - an array of filenames for button state images
        `x` - top-left horizontal distance for the button
        `y` - top left vertical position for the button

  - ### Method Detail

    - #### isOver

          public boolean isOver(int ax,
                       int ay)

      Determines whether the position ax, ay is over this component. It will use a mask image if one has been provided otherwise it will look for non-transparent pixels.
      Overrides:
        `isOver` in class `GComponent`
      Parameters:
        `ax` - mouse x position
        `ay` - mouse y position
      Returns:
        true if mouse is over the component else false

    - #### draw

          public void draw()

      Draw the button
      Overrides:
        `draw` in class `GComponent`

    - #### fireAllEvents

          public void fireAllEvents(boolean all)

      If the parameter is true all 3 event types are generated, if false only CLICKED events are generated (default behaviour).
      Parameters:
        `all` -

    - #### mouseEvent

          public void mouseEvent(MouseEvent event)

      All GUI components are registered for mouseEvents.
      When a button is clicked on a GButton it generates 3 events (in this order) mouse down, mouse up and mouse pressed.
      If you only wish to respond to button click events then you should test the event type e.g.

                  void handleButtonEvents(GButton button) {
                    if(button == btnName && button.eventType == GButton.CLICKED){
                  // code for button click event
              }

      Where

          btnName

      is the GButton identifier (variable name)
      Overrides:
        `mouseEvent` in class `GComponent`

Processing library guicomponents by Peter Lager. (C) 2012