Game Control Plus
1.2.2
|
Classes | |
class | Z_Order |
Public Member Functions | |
MAbstractControl (PApplet theApplet) | |
MAbstractControl (PApplet theApplet, float p0, float p1, float p2, float p3) | |
void | draw () |
void | mouseEvent (MouseEvent event) |
void | keyEvent (KeyEvent e) |
void | pre () |
void | post () |
void | dispose () |
void | forceBufferUpdate () |
boolean | isOver (float x, float y) |
void | setLocalColorScheme (int cs) |
void | setLocalColorScheme (int cs, boolean includeChildren) |
int | getLocalColorScheme () |
void | setAlpha (int alpha) |
void | setAlpha (int alpha, boolean includeChildren) |
MAbstractControl | getParent () |
PApplet | getPApplet () |
PGraphics | getSnapshot () |
void | addEventHandler (Object obj, String methodName) |
void | moveTo (float px, float py) |
float | getX () |
float | getY () |
float | getCX () |
float | getCY () |
float | getWidth () |
float | getHeight () |
void | setVisible (boolean visible) |
boolean | isVisible () |
void | setOpaque (boolean opaque) |
boolean | isOpaque () |
boolean | isDragging () |
void | setEnabled (boolean enable) |
boolean | isEnabled () |
void | setFocus (boolean focus) |
boolean | hasFocus () |
void | addControl (MAbstractControl c, float x, float y, float angle) |
void | addControl (MAbstractControl c, float x, float y) |
void | addControl (MAbstractControl c) |
void | addControls (MAbstractControl...controls) |
int | getCursorOver () |
void | setCursorOver (int cursorOver) |
void | markForDisposal () |
String | toString () |
Public Attributes | |
String | tag |
int | tagNo |
Public Attributes inherited from org.gamecontrolplus.gui.MConstants | |
int | RED_SCHEME = 0 |
int | GREEN_SCHEME = 1 |
int | YELLOW_SCHEME = 2 |
int | PURPLE_SCHEME = 3 |
int | ORANGE_SCHEME = 4 |
int | CYAN_SCHEME = 5 |
int | BLUE_SCHEME = 6 |
int | GOLD_SCHEME = 7 |
int | SCHEME_8 = 8 |
int | SCHEME_9 = 9 |
int | SCHEME_10 = 10 |
int | SCHEME_11 = 11 |
int | SCHEME_12 = 12 |
int | SCHEME_13 = 13 |
int | SCHEME_14 = 14 |
int | SCHEME_15 = 15 |
char | HOME = java.awt.event.KeyEvent.VK_HOME |
char | END = java.awt.event.KeyEvent.VK_END |
int | CTRL_ANGULAR = 0x00000501 |
int | CTRL_HORIZONTAL = 0x00000502 |
int | CTRL_VERTICAL = 0x00000503 |
int | EXIT_APP = 0x00000f01 |
int | CLOSE_WINDOW = 0x00000f02 |
int | KEEP_OPEN = 0x00000f03 |
int | USER_COL_SCHEME = 0x00010102 |
int | ALPHA_BLOCK = 128 |
int | ALPHA_PICK = 48 |
int | SCROLLBARS_NONE = 0x0000 |
int | SCROLLBARS_VERTICAL_ONLY = 0x0001 |
int | SCROLLBARS_HORIZONTAL_ONLY = 0x0002 |
int | SCROLLBARS_BOTH = 0x0003 |
int | SCROLLBARS_AUTOHIDE = 0x1000 |
int | SCROLLBAR_VERTICAL = 1 |
int | SCROLLBAR_HORIZONTAL = 2 |
int | INTEGER = 0 |
int | DECIMAL = 1 |
int | EXPONENT = 2 |
int | ORIENT_LEFT = -1 |
int | ORIENT_TRACK = 0 |
int | ORIENT_RIGHT = 1 |
int | X4 = 1 |
int | X8 = 2 |
int | PLAIN = JOptionPane.PLAIN_MESSAGE |
int | ERROR = JOptionPane.ERROR_MESSAGE |
int | INFO = JOptionPane.INFORMATION_MESSAGE |
int | WARNING = JOptionPane.WARNING_MESSAGE |
int | QUERY = JOptionPane.QUESTION_MESSAGE |
int | YES_NO = JOptionPane.YES_NO_OPTION |
int | YES_NO_CANCEL = JOptionPane.YES_NO_CANCEL_OPTION |
int | OK_CANCEL = JOptionPane.OK_CANCEL_OPTION |
int | OK = JOptionPane.OK_OPTION |
int | YES = JOptionPane.YES_OPTION |
int | NO = JOptionPane.NO_OPTION |
int | CANCEL = JOptionPane.CANCEL_OPTION |
int | CLOSED = JOptionPane.CLOSED_OPTION |
TextAttribute | FAMILY = TextAttribute.FAMILY |
TextAttribute | WEIGHT = TextAttribute.WEIGHT |
Float | WEIGHT_EXTRA_LIGHT = new Float(0.5f) |
Float | WEIGHT_LIGHT = new Float(0.75f) |
Float | WEIGHT_DEMILIGHT = new Float(0.875f) |
Float | WEIGHT_REGULAR = new Float(1.0f) |
Float | WEIGHT_SEMIBOLD = new Float(1.25f) |
Float | WEIGHT_MEDIUM = new Float(1.5f) |
Float | WEIGHT_DEMIBOLD = new Float(1.75f) |
Float | WEIGHT_BOLD = new Float(2.0f) |
Float | WEIGHT_HEAVY = new Float(2.25f) |
Float | WEIGHT_EXTRABOLD = new Float(2.5f) |
Float | WEIGHT_ULTRABOLD = new Float(2.75f) |
TextAttribute | WIDTH = TextAttribute.WIDTH |
Float | WIDTH_CONDENSED = new Float(0.75f) |
Float | WIDTH_SEMI_CONDENSED = new Float(0.875f) |
Float | WIDTH_REGULAR = new Float(1.0f) |
Float | WIDTH_SEMI_EXTENDED = new Float(1.25f) |
Float | WIDTH_EXTENDED = new Float(1.5f) |
TextAttribute | POSTURE = TextAttribute.POSTURE |
Float | POSTURE_REGULAR = new Float(0.0f) |
Float | POSTURE_OBLIQUE = new Float(0.20f) |
TextAttribute | SIZE = TextAttribute.SIZE |
TextAttribute | SUPERSCRIPT = TextAttribute.SUPERSCRIPT |
Integer | SUPERSCRIPT_SUPER = new Integer(1) |
Integer | SUPERSCRIPT_SUB = new Integer(-1) |
Integer | SUPERSCRIPT_OFF = new Integer(0) |
TextAttribute | FOREGROUND = TextAttribute.FOREGROUND |
TextAttribute | BACKGROUND = TextAttribute.BACKGROUND |
TextAttribute | STRIKETHROUGH = TextAttribute.STRIKETHROUGH |
Boolean | STRIKETHROUGH_ON = new Boolean(true) |
Boolean | STRIKETHROUGH_OFF = new Boolean(false) |
Public Attributes inherited from org.gamecontrolplus.gui.MConstantsInternal | |
String | SLIDER_STYLES = "|grey_blue|blue18px|green_red20px|purple18px|red_yellow18px|" |
String | DEFAULT_SLIDER_STYLE = "grey_blue" |
int | DRAW_METHOD = 0x00000001 |
int | MOUSE_METHOD = 0x00000002 |
int | PRE_METHOD = 0x00000004 |
int | KEY_METHOD = 0x00000008 |
int | POST_METHOD = 0x00000010 |
int | ALL_METHOD = 0x0000001f |
int | RUNTIME_ERROR = 0xf0000000 |
int | MISSING = 0x01000001 |
int | NONEXISTANT = 0x01000002 |
int | EXCP_IN_HANDLER = 0x81000003 |
int | OFF_CONTROL = 0 |
int | OVER_CONTROL = 1 |
int | PRESS_CONTROL = 2 |
int | DRAG_CONTROL = 3 |
int | TINT_FOR_ALPHA = 255 |
int | I_NONE = 0 |
int | I_TL = 1 |
int | I_TR = 2 |
int | I_CL = 4 |
int | I_CR = 8 |
int | I_INSIDE = 16 |
int | I_COVERED = 32 |
int | I_MODES = 63 |
int | MERGE_RUNS = 256 |
int | CLIP_RUN = 512 |
int | COMBI_MODES = 768 |
int[][] | grid |
BasicStroke | pen_1_0 = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
BasicStroke | pen_2_0 = new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
BasicStroke | pen_3_0 = new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
BasicStroke | pen_4_0 = new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND) |
Protected Member Functions | |
void | resize (float w, float h) |
int | whichHotSpot (float px, float py) |
int | getCurrHotSpot () |
PGraphics | getBuffer () |
void | updateBuffer () |
void | createEventHandler (Object handlerObj, String methodName, Class[] param_classes, String[] param_names) |
void | fireEvent (Object...objects) |
void | setAvailable (boolean avail) |
boolean | isAvailable () |
void | takeFocus () |
void | loseFocus (MAbstractControl grabber) |
void | addToParent (MAbstractControl p) |
AffineTransform | getTransform (AffineTransform aff) |
void | calcTransformedOrigin (float px, float py) |
void | setZ (int parentZ) |
Static Protected Member Functions | |
static int | focusObjectZ () |
Protected Attributes | |
PApplet | winApp |
int | z = Z_STICKY |
boolean | dragging = false |
MAbstractControl | parent = null |
LinkedList< MAbstractControl > | children = null |
int | localColorScheme = M4P.globalColorScheme |
int[] | palette = null |
Color[] | jpalette = null |
int | alphaLevel = M4P.globalAlpha |
float | x |
float | width |
float | halfWidth |
float | cx |
float | rotAngle |
double[] | temp = new double[2] |
PGraphicsJava2D | buffer = null |
boolean | bufferInvalid = true |
boolean | opaque = false |
int | cursorOver = HAND |
float | ox |
Object | eventHandlerObject = null |
Method | eventHandlerMethod = null |
String | eventHandlerMethodName |
MHotSpot[] | hotspots = null |
int | currSpot = -1 |
Static Protected Attributes | |
static float | epsilon = 0.001f |
Package Attributes | |
float | y |
float | height |
float | halfHeight |
float | cy |
float | oy |
boolean | visible = true |
boolean | enabled = true |
boolean | available = true |
int | registeredMethods = 0 |
Static Package Attributes | |
static MAbstractControl | focusIsWith = null |
static MAbstractControl | controlToTakeFocus = null |
static MAbstractControl | cursorIsOver |
static final int | Z_PANEL = 1024 |
static final int | Z_STICKY = 0 |
static final int | Z_SLIPPY = 24 |
Private Member Functions | |
void | setPositionAndSize (float n0, float n1, float n2, float n3) |
Abstract base class for all GUI controls.
org.gamecontrolplus.gui.MAbstractControl.MAbstractControl | ( | PApplet | theApplet | ) |
Base constructor for ALL control ctors that do not have a visible UI but require access to a PApplet object.
As of V3.5 the only class using this constructor is GGroup
theApplet |
void org.gamecontrolplus.gui.MAbstractControl.addControl | ( | MAbstractControl | c, |
float | x, | ||
float | y, | ||
float | angle | ||
) |
This will set the rotation of the control to angle overwriting any previous rotation set. Then it calculates the centre position so that the original top left corner of the control will be the position indicated by x,y with respect to the top left corner of parent.
The added control will have its position calculated relative to the centre of the parent control.
All overloaded methods call this one.
c | the control to add. |
x | the leftmost or centre position depending on controlMode |
y | the topmost or centre position depending on controlMode |
angle | the rotation angle (replaces any the angle specified in control) |
void org.gamecontrolplus.gui.MAbstractControl.addControl | ( | MAbstractControl | c, |
float | x, | ||
float | y | ||
) |
Add a control at the given position with zero rotation angle.
c | the control to add. |
x | the leftmost or centre position depending on controlMode |
y | the topmost or centre position depending on controlMode |
void org.gamecontrolplus.gui.MAbstractControl.addControl | ( | MAbstractControl | c | ) |
Add a control at the position and rotation specified in the control.
c | the control to add |
void org.gamecontrolplus.gui.MAbstractControl.addEventHandler | ( | Object | obj, |
String | methodName | ||
) |
Attempt to create the default event handler for the component class. The default event handler is a method that returns void and has a single parameter of the same type as the component class generating the event and a method name specific for that class.
obj | the object to handle the event |
methodName | the method to execute in the object handler class |
|
protected |
Changes that need to be made to child when added
p | the parent |
|
protected |
This method takes a position px, py and calculates the equivalent position [ox,oy] as if no transformations have taken place and the origin is the top-left corner of the control.
px | |
py |
|
protected |
Attempt to create the default event handler for the component class. The default event handler is a method that returns void and has a single parameter of the same type as the component class generating the event and a method name specific for that class.
handlerObj | the object to handle the event |
methodName | the method to execute in the object handler class |
param_classes | the parameter classes. |
param_names | that names of the parameters (used for error messages only) |
void org.gamecontrolplus.gui.MAbstractControl.dispose | ( | ) |
This will remove all references to this control in the library.
The user is responsible for nullifying all references to this control in their sketch code.
Once this method is called the control cannot be reused but resources used by the control remain until all references to the control are set to null.
|
protected |
Attempt to fire an event for this component.
The method called must have a single parameter which is the object firing the event. If the method to be called is to have different parameters then it should be overridden in the child class The method
|
staticprotected |
Get the Z order value for the object with focus.
void org.gamecontrolplus.gui.MAbstractControl.forceBufferUpdate | ( | ) |
This is for emergency use only!!!!
In this version of the library a visual controls is drawn to off-screen buffer and then drawn to the screen by copying the buffer. This means that the computationally expensive routines needed to draw the control (especially text controls) are only done when a change has been noted. This means that single changes need not trigger a full redraw to buffer.
It does mean that an error in the library code could result in the buffer not being updated after changes. If this happens then in draw() call this method on the affected control, and report it as an issue here
Thanks
int org.gamecontrolplus.gui.MAbstractControl.getCursorOver | ( | ) |
Get the shape type when the cursor is over a control
float org.gamecontrolplus.gui.MAbstractControl.getCX | ( | ) |
Get the centre x position of the control.
If the control is on a panel then the value returned is relative to the top-left corner of the panel otherwise it is relative to the sketch window display.
float org.gamecontrolplus.gui.MAbstractControl.getCY | ( | ) |
Get the centre y position of the control.
If the control is on a panel then the value returned is relative to the top-left corner of the panel otherwise it is relative to the sketch window display.
float org.gamecontrolplus.gui.MAbstractControl.getHeight | ( | ) |
int org.gamecontrolplus.gui.MAbstractControl.getLocalColorScheme | ( | ) |
Get the local color scheme ID number.
PApplet org.gamecontrolplus.gui.MAbstractControl.getPApplet | ( | ) |
Get the PApplet that manages this component
MAbstractControl org.gamecontrolplus.gui.MAbstractControl.getParent | ( | ) |
Get the parent control. If null then this is a top-level component
PGraphics org.gamecontrolplus.gui.MAbstractControl.getSnapshot | ( | ) |
This method should be used sparingly since it is heavy on resources.
|
protected |
Get an affine transformation that is the compound of all transformations including parents
aff |
float org.gamecontrolplus.gui.MAbstractControl.getWidth | ( | ) |
float org.gamecontrolplus.gui.MAbstractControl.getX | ( | ) |
Get the left position of the control.
If the control is on a panel then the value returned is relative to the top-left corner of the panel otherwise it is relative to the sketch window display.
float org.gamecontrolplus.gui.MAbstractControl.getY | ( | ) |
Get the top position of the control.
If the control is on a panel then the value returned is relative to the top-left corner of the panel otherwise it is relative to the sketch window display.
boolean org.gamecontrolplus.gui.MAbstractControl.hasFocus | ( | ) |
Does this component have focus
|
protected |
Is this control available?
boolean org.gamecontrolplus.gui.MAbstractControl.isEnabled | ( | ) |
Is this component enabled
boolean org.gamecontrolplus.gui.MAbstractControl.isOpaque | ( | ) |
Find out if the component is opaque
boolean org.gamecontrolplus.gui.MAbstractControl.isOver | ( | float | x, |
float | y | ||
) |
Determines if a particular pixel position is over the panel.
boolean org.gamecontrolplus.gui.MAbstractControl.isVisible | ( | ) |
|
protected |
For most components there is nothing to do when they loose focus. Override this method in classes that need to do something when they loose focus eg TextField
void org.gamecontrolplus.gui.MAbstractControl.markForDisposal | ( | ) |
If the control is permanently no longer required then call this method to remove it and free up resources.
The variable identifier used to create this control should be set to null.
For example if you want to dispose of a button called
btnDoThis
then to remove the button use the statements
btnDoThis.dispose();
btnDoThis = null;
void org.gamecontrolplus.gui.MAbstractControl.moveTo | ( | float | px, |
float | py | ||
) |
Move the control to the given position based on the mode.
The position is not constrained to the screen area.
The current control mode determines whether we move the corner or the center of the control to px,py
px | the horizontal position to move to |
py | the vertical position to move to |
|
protected |
Used internally to enforce minimum size constraints
w | the new width |
h | the new height |
void org.gamecontrolplus.gui.MAbstractControl.setAlpha | ( | int | alpha | ) |
Set the transparency of the component and make it unavailable to mouse and keyboard events if below the threshold. Child controls are ignored?
alpha | value in the range 0 (transparent) to 255 (opaque) |
void org.gamecontrolplus.gui.MAbstractControl.setAlpha | ( | int | alpha, |
boolean | includeChildren | ||
) |
Set the transparency of the component and make it unavailable to mouse and keyboard events if below the threshold. Child controls are ignored?
If required include the children and their children.
alpha | value in the range 0 (transparent) to 255 (opaque) |
includeChildren | if do do the same for all descendants |
|
protected |
The availability flag is used by the library code to determine whether a control should be considered for drawing and mouse/key input.
It perits an internal control that does not affect the visible and enabled state of the control, which are set by the programmer.
If a control and its children are made unavailable it will still be drawn but it not respond to user input.
avail |
void org.gamecontrolplus.gui.MAbstractControl.setCursorOver | ( | int | cursorOver | ) |
Set the shape type to use when the cursor is over a control
cursorOver | the shape type to use |
void org.gamecontrolplus.gui.MAbstractControl.setEnabled | ( | boolean | enable | ) |
Enable or disable the ability of the component to generate mouse events.
GTextField - it also controls key press events
GPanel - controls whether the panel can be moved/collapsed/expanded
enable | true to enable else false |
void org.gamecontrolplus.gui.MAbstractControl.setFocus | ( | boolean | focus | ) |
Determines whether this component is to have focus or not
focus |
void org.gamecontrolplus.gui.MAbstractControl.setLocalColorScheme | ( | int | cs | ) |
Set the local colour scheme for this control. Children are ignored.
cs | the colour scheme to use |
void org.gamecontrolplus.gui.MAbstractControl.setLocalColorScheme | ( | int | cs, |
boolean | includeChildren | ||
) |
Set the local colour scheme for this control. Children are ignored. If required include the children and their children.
cs | the colour scheme to use |
includeChildren | if do do the same for all descendants |
void org.gamecontrolplus.gui.MAbstractControl.setOpaque | ( | boolean | opaque | ) |
Determines whether to show the back colour or not. Only applies to some components
opaque |
void org.gamecontrolplus.gui.MAbstractControl.setVisible | ( | boolean | visible | ) |
visible | the visibility to set |
|
protected |
Recursive function to set the priority of a component. This is used to determine who gets focus when components overlap on the screen e.g. when a combobo expands it might cover a button.
It is used where components have childen e.g. GCombo and GPaneln It is used when a child component is added.
component | |
parentZ |
|
protected |
Give the focus to this component but only after allowing the current component with focus to release it gracefully.
Always cancel the keyFocusIsWith irrespective of the component type. If the component needs to retain keyFocus then override this method in that class e.g. GCombo
|
protected |
Stop when we are over a hotspot.
Hotspots should be listed in order of importance.
px | |
py |
|
protected |
The centre of the control
|
protected |
Half sizes reduces programming complexity later
|
protected |
Whether to show background or not
|
protected |
Link to the parent panel (if null then it is on main window)
|
protected |
The angle to control is rotated (radians)
|
protected |
Introduced V3 to speed up AffineTransform operations
|
protected |
Width and height of component in pixels for drawing background (changed form int data type in V3
|
protected |
Top left position of component in pixels (relative to parent or absolute if parent is null) (changed form int data type in V3