# =====================================================================
# WIKI SYSTEM - modificari in: ui.py
# Window: itsRendered/itsNeedDoubleRender/sortIndex + RenderTarget cu evenimente si SetRenderingRect.
# Fiecare bloc de mai jos are cateva linii de context (deasupra / dedesubt)
# ca sa gasesti locul. Liniile sunt numerotate dupa fisierul original din Valiant2.
# =====================================================================

# ---------- [1] liniile 91-94 (context 89-96) ----------
			self.propertyList = {}
		self.exPos = (0,0)
		if app.ENABLE_WIKI:
			self.itsRendered = False
			self.itsNeedDoubleRender = False
			self.sortIndex = 0

	def __del__(self):

# ---------- [2] liniile 7296-7354 (context 7294-7356) ----------
		self.grid = [False] * (self.width * self.height)

if app.ENABLE_RENDER_TARGET:
	class RenderTarget(Window):
		def __init__(self, layer = "UI"):
			Window.__init__(self, layer)
			if app.ENABLE_WIKI:
				self.eventDict={}
				self.eventFunc = {"mouse_click" : None, "mouse_rclick" : None, "mouse_over_in" : None, "mouse_over_out" : None}
				self.eventArgs = {"mouse_click" : None, "mouse_rclick" : None, "mouse_over_in" : None, "mouse_over_out" : None}

		def Destroy(self):
			if app.ENABLE_WIKI:
				self.eventDict={}
				self.eventFunc = 0
				self.eventArgs = 0

		def __del__(self):
			Window.__del__(self)

		def RegisterWindow(self, layer):
			self.hWnd = wndMgr.RegisterRenderTarget(self, layer)

		def SetRenderTarget(self, number):
			wndMgr.SetRenderTarget(self.hWnd, number)

		if app.ENABLE_WIKI:
			def SetRenderingRect(self, left, top, right, bottom):
				wndMgr.SetRenderingRect(self.hWnd, left, top, right, bottom)

			def SetEvent(self, func, *args):
				result = self.eventFunc.has_key(args[0])
				if result:
					self.eventFunc[args[0]] = func
					self.eventArgs[args[0]] = args
				else:
					return

			def OnMouseLeftButtonUp(self) :
				if self.eventFunc["mouse_click"] :
					apply(self.eventFunc["mouse_click"], self.eventArgs["mouse_click"])

			def OnMouseRightButtonDown(self):
				if self.eventFunc["mouse_rclick"] :
					apply(self.eventFunc["mouse_rclick"], self.eventArgs["mouse_rclick"])

			def OnMouseOverIn(self):
				try:
					if self.eventFunc["mouse_over_in"]:
						if self.eventArgs:
							apply(self.eventFunc["mouse_over_in"], self.eventArgs["mouse_over_in"])
						else:
							self.eventFunc["mouse_over_in"]()
				except KeyError:
					pass

			def OnMouseOverOut(self):
				try:
					if self.eventFunc["mouse_over_out"]:
						if self.eventArgs:
							apply(self.eventFunc["mouse_over_out"], self.eventArgs["mouse_over_out"])
						else:
							self.eventFunc["mouse_over_out"]()
