# -*- coding: UTF-8 -*-
""" Test.py - code file for form 'Test'
	Thomas Führinger, 2003-09-08
"""

import Form, Ui, ToolBox

def Dummy_OpenChild_Clicked(Widget, self):
	"Trigger for item 'OpenChild' of block 'Dummy' tied to event 'Clicked'"

	self.Block.Form.Window["Child"].Display()
	

def Dummy_CloseChild_Clicked(Widget, self):
	"Trigger for item 'CloseChild' tied to event 'Clicked'"

	self.Canvas.Window.Close()
	

def TestMaster_ValueTotal_Function(self):
	"Function for item 'ValueTotal' of block 'test_master'"
	
	return self.Block.Form.Block["TestDetail1"].Item["Value"].GetValueSum()


def TestDetail1_Repopulated(self):
	"Trigger for block 'test_detail_1' tied to event 'Repopulated'"
	
	self.Form.Block["TestMaster"].Item["ValueTotal"].DisplayBuffer()


def TestDetail1_DateValue_Validate(self):
	"Validation function for item 'DateValue' of block 'test_detail_1'"
	
	if self.GetScreenValue() < ToolBox.ParseDateTime("1970-06-14", "%Y-%m-%d"):
		Ui.Message("Dates prior to 1970-06-14 are not allowed!")
		return False
	else:
		return True
	

def TestDetail2_Calculated_Function(self):
	"Function for item 'Calculated' of block 'test_detail_2'"
	
	return ToolBox.Coalesce(self.Block.Item["Rank"].GetValue(), 0) * 2
	
