User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
guisys:predefined_methods [2006-09-07 15:05]
Carsten created; much enhanced copy of scripting:windowdef
— (current)
Line 1: Line 1:
-====== Predefined Methods ====== 
- 
-This section lists all methods that the GuiSys (C++) code predefines for the GUI windows of all window classes. These methods are intended to be called from your Lua scripts for convenient access to the window details. These are the key methods for setting up and customizing the windows of your GUI. 
- 
-Currently, all methods are available for all window classes (''​windowClass'',​ ''​editClass'',​ etc.), and behave identically. 
-Deviations from this rule are mentioned explicitly in the respective documentation below. 
- 
- 
-====== ====== 
-==== set(var, value) ==== 
- 
-Sets the window variable with name ''​var''​ to the given value. 
- 
-=== Parameters: === 
-^ Name ^ Type ^ Description ^ 
-| var | string | The name of the variable to set. All valid names are listed in the table below. | 
-| value | See table below. | The value to set the variable to. | 
- 
-=== Returns: === 
-Nothing (nil). 
- 
-=== Notes: === 
-Many variables are tuples of 2 or 4 individual values. E.g. all color values have a red, green, blue and alpha component, and positions have an x- and y-component. Therefore, for many variables there is a form with which you can set all components at once, and forms with which you can set a subset of the components. 
- 
-Here is a list with all variable names that you can use for ''​var'',​ in logically grouped order. The second column indicates how many arguments and their related types are expected. 
- 
-^ Name ^ Type ^ Remarks ^ 
-| show | bool  | If this window is shown. | 
-| time | float | Automatically incremented on each frame, but can freely be modified. | 
-| rotAngle | float | The angle of rotation of this window, in degrees (0..360). | 
-| ||| 
-^ Name ^ Type ^ Remarks ^ 
-| rect | float, float, float, float | The (x, y) position and (width, height) dimensions of this window. The position is relative to the parent window. | 
-| pos  | float, float               | Just the first two components of ''​rect'':​ the (x, y) position, relative to the parent window. | 
-| size | float, float               | Just the last two components of ''​rect'':​ The width and height. | 
-| pos.x | float | The x-position of this window (1st component of ''​rect''​). | 
-| pos.y | float | The y-position of this window (2nd component of ''​rect''​). | 
-| size.x | float | The width of this window (3rd component of ''​rect''​). | 
-| size.y | float | The height of this window (4th component of ''​rect''​). | 
-| ||| 
-^ Name ^ Type ^ Remarks ^ 
-| backMaterial | string ​                    | The name of the MatSys material to be used as the background image of this window. | 
-| backColor ​  | float, float, float, float | The red, green, blue and alpha components of the background color. | 
-| backColor.r | float                      | The red component of the background color. | 
-| backColor.g | float                      | The green component of the background color. | 
-| backColor.b | float                      | The blue component of the background color. | 
-| backColor.a | float                      | The alpha component of the background color. | 
-| ||| 
-^ Name ^ Type ^ Remarks ^ 
-| borderWidth ​  | float                      | The width of the border frame. | 
-| borderColor ​  | float, float, float, float | The red, green, blue and alpha components of the border color. | 
-| borderColor.r | float                      | The red component of the border color. | 
-| borderColor.g | float                      | The green component of the border color. | 
-| borderColor.b | float                      | The blue component of the border color. | 
-| borderColor.a | float                      | The alpha component of the border color. | 
-| ||| 
-^ Name ^ Type ^ Remarks ^ 
-| font         | string ​                    | The name of the font to render the text with. | 
-| text         | string ​                    | The text to display in this window. | 
-| textColor ​   | float, float, float, float | The red, green, blue and alpha components of the text color. | 
-| textColor.r ​ | float                      | The red component of the text color. | 
-| textColor.g ​ | float                      | The green component of the text color. | 
-| textColor.b ​ | float                      | The blue component of the text color. | 
-| textColor.a ​ | float                      | The alpha component of the text color. | 
-| textScale ​   | float                      | The relative size of the text. 1 = 48pt, 0.5 = 24pt, etc. | 
-| textAlignHor | int                        | The horizontal text alignment mode: 0 = left (default), 1 = right, 2 = center. | 
-| textAlignVer | int                        | The vertical text alignment mode: 0 = top (default), 1 = bottom, 2 = middle. | 
- 
-  * Also note that all coordinates are given with regards to the "​virtual screen coordinate system",​ which has a resolution of 640 * 480 pixels and is automatically scaled to the true resolution. 
-  * Color components (red, green, blue and alpha) are always given in percent, that is, as fractional values between 0 and 1. 
- 
-=== Example: === 
-<​code=lua>​ 
-    function ConsoleFrame:​OnInit() 
-        self:​set("​rect",​ 20, 20, 600, 440); 
-        self:​set("​backColor",​ 0.82, 0.49, 0.17, 0.2); 
-        self:​set("​borderWidth",​ 0.7); 
-        self:​set("​borderColor",​ 0.82, 0.49, 0.17, 1.0); 
-        self:​set("​text",​ "​Hello!"​);​ 
-    end 
-</​code>​ 
- 
- 
-====== ====== 
-==== get(var) ==== 
- 
-Returns the value the window variable. 
- 
-=== Parameters: === 
-^ Name ^ Type ^ Description ^ 
-| var | string | The name of the variable whose value should be returned. | 
- 
-=== Returns: === 
-The value of the desired variable in the appropriate type. 
- 
-As Lua supports //tuples// as return types, this method works with all variables listed at the [[#​set_name_value|set()]] method, except for "​backMaterial"​ and "​font",​ which are write-only. 
- 
- 
-=== Notes: === 
-  * Cannot be used with the variables "​backMaterial"​ and "​font",​ as they are write-only. 
- 
-=== Example: === 
-<​code=lua>​ 
-    function RotatingWin:​OnFrame() 
-        self:​set("​rotAngle",​ self:​get("​time"​)*50);​ 
-    end 
- 
-    function OtherWin:​OnAction() 
-        -- Toggle the hor. text alignment of RotatingWin. 
-        local newAlign=RotatingWin:​get("​textAlignHor"​)+1;​ 
-        if (newAlign>​2) then newAlign=0; end 
- 
-        RotatingWin:​set("​textAlignHor",​ newAlign); 
-    end 
-</​code>​ 
- 
- 
-====== ====== 
-==== interpolate(var,​ s, e, t) ==== 
- 
-Interpolates the value of the given variable from start value ''​s''​ to end value ''​e''​ over time ''​t''​. 
- 
-=== Parameters: === 
-^ Name ^ Type ^ Description ^ 
-| var | string | The name of the variable to interpolate. | 
-| s | number | The start value. | 
-| e | number | The end value. | 
-| t | number | The time to interpolate over, given in milliseconds. | 
- 
-=== Returns: === 
-Nothing (nil). 
- 
-=== Notes: === 
-  * For ''​var''​ only variables of type __float__ are allowed, see [[#​set_name_value|set()]] for a list. 
- 
-=== Example: === 
-<​code=lua>​ 
-    function ButtonOK:​OnMouseEnter() 
-        self:​interpolate("​rotAngle",​ 0, 360, 250); 
-        self:​interpolate("​textScale",​ 0.2, 0.25, 500); 
-        self:​interpolate("​pos.y",​ 300, 380, 750); 
-    end 
-</​code>​ 
- 
- 
-====== ====== 
-==== __tostring() ==== 
- 
-Returns a short string that describes the window. 
- 
-=== Parameters: === 
-None. 
- 
-=== Returns: === 
-A short string that describes the window. 
- 
-=== Notes: === 
-  * This method is not intended to be called directly. Rather, it's the metamethod for Luas ''​tostring()''​ method that allows the conversion of a window into a string. 
- 
-=== Example: === 
-This method makes the following examples work: 
-<​code=lua>​ 
-    s=tostring(myWin); ​   -- myWin is a GuiSys window object (which has the __tostring() metamethod). 
-    print(s); 
- 
-    print(myWin); ​        -- Same as:   ​print(tostring(myWin));​ 
-</​code>​ 
  
guisys/predefined_methods.1157634317.txt.gz ยท Last modified: 2013-01-07 12:07 (external edit)