GetMathErrValStr Include

GetViewportSize


The GetViewportSize function returns the width and height of the interior of the main Mira window.

Syntax

w, h = GetViewportSize()

Example

The script fragment below shows how to create a text output window having a specified width and height. The CreateTextWindowfunction accepts relative dimensions rather than absolute ones. For example, it takes a Window rectangle like (0.1, 0.7, 0.1, 0.6) relative to the size of the main Mira window. To create a Text Editor window that is 600 pixels wide x 400 pixels tall, anchored at the upper left corner, we would do the following:

 

function MakeTextWnd(sTitle,w,h)

-- make a function to do this

  local wMira,hMira = GetViewportSize()

-- maximum width and height

  local R = CRect:new()

-- create a CRect object

  R:Set(0,w/wMira,0,h/hMira)

-- scale to the viewport

  local W = CreateTextWindow(sTitle,R)

-- format the string

  R:delete()

-- no longer needed.

  return W

-- return the window reference

end

 

 

 

T = MakeTextWnd("My Title",600,400)

-- is returned the window pointer T

Related Topics

CRect