Creation/Dev/Script/Client/GuiStretchCtrl: Difference between revisions

From Graal Bible
m (→‎Description: Fixed a spelling error)
No edit summary
 
Line 1: Line 1:
[[Category:Scripting Reference]]
Inherits [[Creation/Dev/Script/Client/GuiControl|GuiControl]].
Inherits [[Creation/Dev/Script/Client/GuiControl|GuiControl]].



Latest revision as of 23:56, 15 February 2010

Inherits GuiControl.

Description

Guicontrol stretch.png

This control stretches the content (client controls) to the current size of the control. Define clientwidth and clientheight (or clientextent) to say which area should be stretched to the actual size.

Use globalToLocalCoord() and localToGlobalCoord() to translate between real mouse positions and scaled positions inside the control.

GuiStretchCtrl can make it easier to do games inside the GUI since you don't need to care about resizing, you can just use absolut coordinates and the GuiStretchCtrl is automatically stretching the graphics and text and is translating mouse positions to correctly hit the buttons and other controls.

Variables

clientwidth - integer, defines the width of the area to stretch

clientheight - integer, defines the height of the area to stretch

clientextent - of format {width,height}, combination of clientwidth and clientheight


Example

new GuiStretchCtrl("Test_Stretch") {
  x = 10;
  y = 10;
  width = 160;
  height = 120;
  clientwidth = 176;
  clientheight = 70;
    
  new GuiShowImgCtrl("Test_StretchContent1") {
    x = 0;
    y = 0;
    image = "2002_sysmsgbg.png";
    width = 176;
    height = 70;
  }
    
  new GuiButtonCtrl("Test_StretchContent2") {
    profile = GuiButtonProfile;
    x = 38;
    y = 30;
    width = 100;
    height = 30;
    text = "Stretch";
  }
}