Newer
Older
invertedlogic / LGN-IP3870 / qtpyui / device-files / diffs / calculator-test.diff
--- ../t/lgvp_py/menu.py	2009-01-05 18:10:34.000000000 +0900
+++ menu.py	2009-01-08 21:10:34.000000000 +0900
@@ -2217,6 +2217,37 @@
 		stage = videosetting.get_stage(index)
 		runtime.manager.stack_stage(stage)
 
+
+class ExampleCalculatorStage(Stage):
+	title = _('CALCULATOR')
+	name = 'Calculator'
+	def __init__(self):
+		# in this example, the title, background and menu are drawn from python using baseui
+		self.ui = baseui.BaseUI('OK','AC',self.title,'CLR','BACK')
+		# this example calculator widget will be drawn in to the python stage
+		self.calc = runtime.evas.widgetExample();
+		self.ui.add(self.calc)
+		# install key hander in the python environment and pass through
+		#  keys back to C++ to the widget
+		self.tmpkey = runtime.evas.handle_key;
+		runtime.evas.handle_key = self.handle_key
+
+	def handle_key(self, down, key):
+		# filter keys first before passing to ui
+		if key == config.Menu4 or key == 'CLR':
+			# Can add any extra key filtering for system events here
+			runtime.manager.back_stage()
+			return True
+		else:
+			# send key to the ui
+			return self.calc.handle_key(down, key)
+
+	def destroy(self):
+		# uninstall the keyboard handler and cleanup
+		runtime.evas.handle_key = self.tmpkey;
+		self.ui.destroy()
+
+
 # KA: [20080218] Volume
 #class AudioSettingStage(ListStage): 
 class SoundStage(ListStage):
@@ -2231,8 +2262,8 @@
 	icon = uiconfig.setting_audio_icon
 	#titleimage = uiconfig.title_sound
 	def __init__(self):
-        ListStage.__init__(self, self.choice, self.title, self.icon)
-        #status.supervision_not_allowed = 1
+		ListStage.__init__(self, self.choice, self.title, self.icon)
+		#status.supervision_not_allowed = 1
 		
 	def activate(self, index):
 		if index == 0:
@@ -9730,7 +9761,8 @@
 
 		runtime.manager.stack_stage(stage)
 
-_stages = MyAnnStage, PhoneBookStage, MessageStage, ServiceStage, MultimediaStage, SoundStage, ScreenStage, SettingStage
+# _stages = MyAnnStage, PhoneBookStage, MessageStage, ServiceStage, MultimediaStage, SoundStage, ScreenStage, SettingStage
+_stages = MyAnnStage, PhoneBookStage, MessageStage, ServiceStage, MultimediaStage, ExampleCalculatorStage, ScreenStage, SettingStage
 
 def get_stage(index):
 	return _stages[index]