(* Use only the following Wimdows things in combination with JJ3D *) DEFINITION MODULE Wimdows; (* Creates a color with red, green and blue components in the range 0 to 255 -- *) PROCEDURE RgbColor( r, g, b: CARDINAL ): CARDINAL; (* Creates a new color which is percentage% lighter than the given color. If negative, a darker color is returned *) PROCEDURE Lighter( color: CARDINAL; percentage: INTEGER ): CARDINAL; (* Creates a new color which is percentage% darker than the given color. If negative, a lighter color is returned *) PROCEDURE Darker( color: CARDINAL; percentage: INTEGER ): CARDINAL; (* --- Keyboard and mouse --- *) (* KeyDown takes a key code as a parameter which can be any alphabetical character or a virtual key code for special keys. * Example: * pressed := KeyDown( ORD('B') ); * returns TRUE if the 'b' key is pressed. * * GetKey returns the last key of a key buffer. This buffer is created after calling Window and is destroyed when * the window is closed. If there is no key in the buffer GetKey waits until the user presses one. * GetKeyPressed is the non-blocking version of GetKey. This procedure will fill in the variable 'key' and return TRUE * if there are any keys in the buffer. If the buffer is empty it will immediatly return FALSE. * * All keys stay in the keybuffer until GetKey or GetKeyPressed is called or the buffer is cleared with FlushKeys. * * The virtual key codes should be imported from Windows like this: * FROM Windows IMPORT VK_LEFT; * ... * pressed := KeyDown( VK_LEFT ); * * The virtual key codes can be found on this website: * http://msdn2.microsoft.com/en-us/library/ms927178.aspx *) (* Checks if a certain key is pressed -- *) PROCEDURE KeyDown( k: CARDINAL ): BOOLEAN; (* Returns the pressed key -- *) PROCEDURE GetKey(): CARDINAL; (* Checks if there are any keys pressed *) PROCEDURE GetKeyPressed(VAR key : CARDINAL): BOOLEAN; (* Clears the key buffer -- *) PROCEDURE FlushKeys; (* Returns the position of the mouse cursor -- *) PROCEDURE MousePos( VAR x, y: INTEGER ); (* Checks if the left mouse button is pushed -- *) PROCEDURE MouseLeft(): BOOLEAN; (* Checks if the right mouse button is pushed -- *) PROCEDURE MouseRight(): BOOLEAN; (* --- Advanced mouse procedures --- *) (* How OnMouseLeft, OnMouseRight and OnMouseDouble work: * These procedures take the name of another procedure as a parameter. If you have a procedure * with the name MyLeftMouseProcedure, you would write: * OnMouseLeft( MyLeftMouseProcedure ); * From now on MyLeftMouseProcedure will be called whenever the user clicks the left mouse button. * * You can stop the procedure from being executed by saying: * StopOnMouseLeft; * * The MyLeftMouseProcedure should be in the following form: PROCEDURE( INTEGER, INTEGER ); * It has 2 parameters which represent the x and y coördinates of the mouse cursor when the procedure is called. *) TYPE MouseProc = PROCEDURE( INTEGER, INTEGER ); (* A sample MyLeftMouseProcedure would look like this: * * PROCEDURE MyLeftMouseProcedure( x, y: INTEGER ); * BEGIN * DoWhateverYouWant; * END MyLeftMouseProcedure; * * And it would be activated in the main program by calling: * OnMouseLeft( MyLeftMouseProcedure ); *) (* Executes the specified procedure when the user clicks the left mouse button or releases it -- *) PROCEDURE OnMouseLeft( proc: MouseProc ); PROCEDURE OnMouseLeftUp( proc: MouseProc ); (* Executes the specified procedure when the user clicks the right mouse button or releases it -- *) PROCEDURE OnMouseRight( proc: MouseProc ); PROCEDURE OnMouseRightUp( proc: MouseProc ); (* Executes the specified procedure when the user double-clicks -- *) PROCEDURE OnMouseDouble( proc: MouseProc ); (* Stops executing the procedure when the user clicks -- *) PROCEDURE StopOnMouseLeft; PROCEDURE StopOnMouseLeftUp; PROCEDURE StopOnMouseRight; PROCEDURE StopOnMouseRightUp; PROCEDURE StopOnMouseDouble; END Wimdows.