Game Control Plus  1.2.2
 All Classes Namespaces Functions Variables Pages
org.gamecontrolplus.gui.M4P Class Reference
Inheritance diagram for org.gamecontrolplus.gui.M4P:

Classes

class  G4Pstyle
 

Static Public Member Functions

static String getPrettyVersion ()
 
static String getVersion ()
 
static void registerSketch (PApplet app)
 
static void setGlobalColorScheme (int cs)
 
static void setWindowColorScheme (PApplet app, int cs)
 
static void setGlobalAlpha (int alpha)
 
static void setWindowAlpha (PApplet app, int alpha)
 
static void messagesEnabled (boolean enable)
 
static void setMouseOverEnabled (boolean enable)
 
static void setCursorOff (int cursorOff)
 
static void setCursor (int cursorOff)
 
static int getCursor ()
 
static int getCursorOff ()
 
static ArrayList< MWindowgetOpenWindowsAsList (ArrayList< MWindow > list)
 
static MWindow[] getOpenWindowsAsArray ()
 
static boolean isWindowOpen (MWindow window)
 
static String selectFolder (String prompt)
 
static String selectInput (String prompt)
 
static String selectInput (String prompt, String types, String typeDesc)
 
static String selectOutput (String prompt)
 
static String selectOutput (String prompt, String types, String typeDesc)
 
static void showMessage (PApplet owner, String message, String title, int messageType)
 
static int selectOption (PApplet owner, String message, String title, int messageType, int optionType)
 

Static Package Functions

static void registerWindow (MWindow window)
 
static void deregisterWindow (MWindow window)
 
static void registerControl (MAbstractControl control)
 
static boolean removeControl (MAbstractControl control)
 
static void pushStyle ()
 
static void popStyle ()
 

Static Package Attributes

static PApplet sketchWindow = null
 
static MWindowImpl sketchWindowImpl = null
 
static List< MWindowallWindows = new LinkedList<MWindow>()
 
static int globalColorScheme = MCScheme.BLUE_SCHEME
 
static int globalAlpha = 255
 
static Font globalFont = new Font("Dialog", Font.PLAIN, 12)
 
static Font numericLabelFont = new Font("DialogInput", Font.BOLD, 12)
 
static MAbstractControl.Z_Order zorder = new MAbstractControl.Z_Order()
 
static boolean cursorChangeEnabled = true
 
static int mouseOff = ARROW
 
static boolean showMessages = true
 
static LinkedList< G4Pstylestyles = new LinkedList<G4Pstyle>()
 
static JColorChooser chooser = null
 
static Color lastColor = Color.white
 

Static Private Member Functions

static String selectImpl (String prompt, int mode, String types, String typeDesc)
 
static Frame getFrame (PApplet owner)
 

Static Private Attributes

static String PANE_TEXT_STYLE_MACOS
 
static String PANE_TEXT_STYLE_OTHER
 

Additional Inherited Members

- 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)
 

Detailed Description

The core class for the global manipulation and execution of G4P.
It also gives access to many of the constants used in this library.

Author
Peter Lager

Member Function Documentation

static void org.gamecontrolplus.gui.M4P.deregisterWindow ( MWindow  window)
staticpackage

De-register a window , this is done when a window is closed

Parameters
window
static int org.gamecontrolplus.gui.M4P.getCursor ( )
static

Get the cursor shape used when the mouse is not over a G4P control set for the

static int org.gamecontrolplus.gui.M4P.getCursorOff ( )
static
static Frame org.gamecontrolplus.gui.M4P.getFrame ( PApplet  owner)
staticprivate

Find the Frame associated with this object.

Parameters
ownerthe object that is responsible for this message
Returns
the frame (if any) that owns this object
static MWindow [] org.gamecontrolplus.gui.M4P.getOpenWindowsAsArray ( )
static

Get an array of MWindow objects even if minimised or invisible.
This method never returns null, if there are no open windows the array will be of length zero.

Returns
an array of references to all open MWindow objects.
static ArrayList<MWindow> org.gamecontrolplus.gui.M4P.getOpenWindowsAsList ( ArrayList< MWindow list)
static

Get a list of all open MWindow objects even if minimised or invisible.
If an ArrayList is provided then its contents are cleared before adding references to all open MWindow objects. If an ArrayList is not provided then a new ArrayList will be created.
This method never returns null, if there are no open windows the list will be of size zero.

Parameters
listan optional ArrayList to use. In null will create a new ArrayList.
Returns
an ArrayList of references to all open MWindow objects.
static String org.gamecontrolplus.gui.M4P.getPrettyVersion ( )
static

return the pretty version of the library.

static String org.gamecontrolplus.gui.M4P.getVersion ( )
static

return the version of the library used by Processing

static boolean org.gamecontrolplus.gui.M4P.isWindowOpen ( MWindow  window)
static

Use this to check whether a MWindow window is still open (as far as G4P is concerned).

Parameters
windowthe window we are interested in
Returns
true if G4P still thinks it is open
static void org.gamecontrolplus.gui.M4P.messagesEnabled ( boolean  enable)
static

G4P has a range of support messages eg
if you create a GUI component without an event handler or,
a slider where the visible size of the slider is less than the difference between min and max values.

This method allows the user to enable (default) or disable this option. If disable then it should be called before any GUI components are created.

If you are adding your own event handlers then I suggest that you disable messages.

Parameters
enable
static void org.gamecontrolplus.gui.M4P.popStyle ( )
staticpackage

Remove and restore the current style from the stack.
There should be a matching pushStyle otherwise the program will crash.

static void org.gamecontrolplus.gui.M4P.pushStyle ( )
staticpackage

Save the current style on a stack.
There should be a matching popStyle otherwise the program it will cause a memory leakage.

static void org.gamecontrolplus.gui.M4P.registerControl ( MAbstractControl  control)
staticpackage

Used internally to register a control with its window. It will replace the addControl method in the controls constructors

Parameters
control
static void org.gamecontrolplus.gui.M4P.registerSketch ( PApplet  app)
static

Used to register the main sketch window with G4P. This is ignored if any G4P controls or windows have already been created because the act of creating a control will do this for you.

Some controls are created without passing a reference to the sketch applet but still need to know it. An example is the GColorChooser control which cannot be used until this method is called or some other G4P control has been created.

Also some other libraries such as PeasyCam change the transformation matrix. In which case either a G4P control should be created or this method called before creating a PeasyCam object.

Parameters
app
static void org.gamecontrolplus.gui.M4P.registerWindow ( MWindow  window)
staticpackage

Register a MWindow so we can keep track of all GWindows in the application. This will be needed for global transformations e.g. setGlobalAlpha(...) This is called from the controls constructor, and also when a MWindow is created.

Parameters
window
static boolean org.gamecontrolplus.gui.M4P.removeControl ( MAbstractControl  control)
staticpackage

Display the library version in the ProcessingIDE Remove a control from the window. This is used in preparation for disposing of a control.

Parameters
control
Returns
true if control was remove else false
static String org.gamecontrolplus.gui.M4P.selectFolder ( String  prompt)
static

This will open a version of the Java Swing color chooser dialog. The dialog's UI is dependent on the OS and JVM implementation running.

If you click on Cancel then it returns the last color previously selected.

Returns
the ARGB colour as a 32 bit integer (as used in Processing). Select a folder from the local file system.
Parameters
promptthe frame text for the chooser
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String org.gamecontrolplus.gui.M4P.selectImpl ( String  prompt,
int  mode,
String  types,
String  typeDesc 
)
staticprivate

The implementation of the select input and output methods.

Parameters
prompt
mode
types
typeDesc
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String org.gamecontrolplus.gui.M4P.selectInput ( String  prompt)
static

Select a file for input from the local file system.

Parameters
promptthe frame text for the chooser
Returns
the absolute path name for the selected folder, or null if action cancelled.
static String org.gamecontrolplus.gui.M4P.selectInput ( String  prompt,
String  types,
String  typeDesc 
)
static

Select a file for input from the local file system.

This version allows the dialog window to filter the output based on file extensions. This is not available on all platforms, if not then it is ignored.

It is definitely available on Linux systems because it uses the standard Swing JFileFinder component.

Parameters
promptthe frame text for the chooser
typesa comma separated list of file extensions e.g. "png,gif,jpg,jpeg"
typeDescsimple textual description of the file types e.g. "Image files"
Returns
the absolute path name for the selected folder, or null if action cancelled.
static int org.gamecontrolplus.gui.M4P.selectOption ( PApplet  owner,
String  message,
String  title,
int  messageType,
int  optionType 
)
static

Display a simple message dialog window.

The actual UI will depend on the platform your application is running on.

The message type should be one of the following
G4P.PLAIN, G4P.ERROR, G4P.INFO, G4P.WARNING, G4P.QUERY

The option type should be one of the following
G4P.YES_NO, G4P.YES_NO_CANCEL, G4P.OK_CANCEL

This method returns a value to indicate which button was clicked. It will be one of the following
G4P.OK, G4P.YES, G4P.NO, G4P.CANCEL, G4P.CLOSED

Some comments on the returned value:

  • G4P.OK and G4P.YES have the same integer value so can be used interchangeably.
  • G4P.CLOSED maybe returned if the dialog box is closed although on some systems G4P.NO or G4P.CANCEL may be returned instead.
  • It is better to test for a positive response because they have the same value.
  • If you must test for a negative response use !G4P.OK or !G4P.YES
Parameters
ownerthe control responsible for this dialog.
messagethe text to be displayed in the main area of the dialog
titlethe text to appear in the dialog's title bar.
messageTypethe message type
optionType
Returns
which button was clicked
static String org.gamecontrolplus.gui.M4P.selectOutput ( String  prompt)
static

Select a file for output from the local file system.

Parameters
promptthe frame text for the chooser
Returns
the absolute path name for the selected folder, or null if action is cancelled.
static String org.gamecontrolplus.gui.M4P.selectOutput ( String  prompt,
String  types,
String  typeDesc 
)
static

Select a file for output from the local file system.

This version allows the dialog window to filter the output based on file extensions. This is not available on all platforms, if not then it is ignored.

It is definitely available on Linux systems because it uses the standard swing JFileFinder component.

Parameters
promptthe frame text for the chooser
typesa comma separated list of file extensions e.g. "png,jpf,tiff"
typeDescsimple textual description of the file types e.g. "Image files"
Returns
the absolute path name for the selected folder, or null if action cancelled.
static void org.gamecontrolplus.gui.M4P.setCursor ( int  cursorOff)
static

Set the cursor shape to be used when the mouse is not over a G4P control for the entire application including secondary windows.

Parameters
cursorOffthe cursor shape.
static void org.gamecontrolplus.gui.M4P.setCursorOff ( int  cursorOff)
static
static void org.gamecontrolplus.gui.M4P.setGlobalAlpha ( int  alpha)
static

Set the transparency of all controls. If the alpha level for a control falls below G4P.ALPHA_BLOCK then it will no longer respond to mouse and keyboard events.

Parameters
alphavalue in the range 0 (transparent) to 255 (opaque)
static void org.gamecontrolplus.gui.M4P.setGlobalColorScheme ( int  cs)
static

Set the global colour scheme. This will change the local colour scheme for every control.

Parameters
cscolour scheme to use (0-15)
static void org.gamecontrolplus.gui.M4P.setMouseOverEnabled ( boolean  enable)
static

Enables or disables cursor over component change.

Calls to this method are ignored if no G4P controls have been created.

Parameters
enabletrue to enable cursor change over components.
static void org.gamecontrolplus.gui.M4P.setWindowAlpha ( PApplet  app,
int  alpha 
)
static

Set the transparency level for all controls drawn by the given PApplet. If the alpha level for a control falls below G4P.ALPHA_BLOCK then it will no longer respond to mouse and keyboard events.

Parameters
app
alphavalue in the range 0 (transparent) to 255 (opaque)
static void org.gamecontrolplus.gui.M4P.setWindowColorScheme ( PApplet  app,
int  cs 
)
static

Versions of G4P prior to 3.5 used logical fonts for the controls. So if you have old sketches then the text may look different with this and later versions of G4P.
If this is causing a problem then call this method before creating any controls. Set the colour scheme for all the controls drawn by the given PApplet. This will override any previous colour scheme for these controls.

Parameters
app
cs
static void org.gamecontrolplus.gui.M4P.showMessage ( PApplet  owner,
String  message,
String  title,
int  messageType 
)
static

Display a simple message dialog window.

The actual UI will depend on the platform your application is running on.

The message type should be one of the following
G4P.PLAIN, G4P.ERROR, G4P.INFO, G4P.WARNING, G4P.QUERY

Parameters
ownerthe control responsible for this dialog.
messagethe text to be displayed in the main area of the dialog
titlethe text to appear in the dialog's title bar.
messageTypethe message type

Member Data Documentation

String org.gamecontrolplus.gui.M4P.PANE_TEXT_STYLE_MACOS
staticprivate
Initial value:
= "<html> <head> <style type=\"text/css\">"+
"b { font: 13pt \"Lucida Grande\" } p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
"</style> </head> <b>@@TITLE@@</b> <p>@@MESSAGE@@</p>"
String org.gamecontrolplus.gui.M4P.PANE_TEXT_STYLE_OTHER
staticprivate
Initial value:
= "<html> <head> <style type=\"text/css\">"+
"b { font: 12pt \"Lucida Grande\" } p { font: 11pt \"Lucida Grande\"; margin-top: 8px }"+
"</style> </head> <b>@@MESSAGE@@ </b>"