Lua:Neutrino-API:ParentWindow:en

Aus TuxBoxWIKI
Wechseln zu: Navigation, Suche

Parent Window

Mostly component class based objects (currently: ctext, cpicture and signalbox) supports parameters for parent object (parent window) on initialization.

Advantages:

  • all positions are relativ to parent window body, in which 'body' is the area below lower edge of header and upper edge of footer, means: x=0 left within body, y = 0 top within body.
  • paint() / hide() are not absolutely necessary, it's enough to paint or hide the parent window
  • also a window itself can be a child object
  • it's possible to interleave objects


Example:

local n = neutrino()

local x  = 200
local y  = 120
local dx = 910
local dy = 480

local vSpace  = 40
local xStart  = 10
local yStart  = 20

-- parent Window
local w = cwindow.new{x=x, y=y, dx=dx, dy=dy, title="Lua Neutrino-API: parent window", icon="info", btnRed="Ende"}

-- cpicture item
cpicture.new{parent=w, x=xStart, y=yStart         , dx=40, dy=40, image="rot"}
cpicture.new{parent=w, x=xStart, y=yStart+vSpace*1, dx=40, dy=40, image="gruen"}
cpicture.new{parent=w, x=xStart, y=yStart+vSpace*2, dx=40, dy=40, image="gelb"}
cpicture.new{parent=w, x=xStart, y=yStart+vSpace*3, dx=40, dy=40, image="blau"}
cpicture.new{parent=w, x=xStart, y=yStart+vSpace*4, dx=40, dy=40, image="info"}
cpicture.new{parent=w, x=xStart, y=yStart+vSpace*5, dx=40, dy=40, image="help"}

-- ctext item
ctext.new{parent=w, x=xStart+60, y=yStart         , dx=dx-80, dy=40, text="Dieses ist der rote Knopp.", font_text=FONT['MENU']}
ctext.new{parent=w, x=xStart+60, y=yStart+vSpace*1, dx=dx-80, dy=40, text="2. Zeile...", font_text=FONT['MENU']}
ctext.new{parent=w, x=xStart+60, y=yStart+vSpace*2, dx=dx-80, dy=40, text="usw. ...", font_text=FONT['MENU']}
ctext.new{parent=w, x=xStart+60, y=yStart+vSpace*3, dx=dx-80, dy=40, text="usw. ...", font_text=FONT['MENU']}
ctext.new{parent=w, x=xStart+60, y=yStart+vSpace*4, dx=dx-80, dy=40, text="usw. ...", font_text=FONT['MENU']}
ctext.new{parent=w, x=xStart+60, y=yStart+vSpace*5, dx=dx-80, dy=40, text="usw. ...", font_text=FONT['MENU']}

-- paint window and all items at once
w:paint()

repeat
	msg, data = n:GetInput(500)
until msg == RC['home'] or msg == RC['red']

w:hide()


Beispiel 1