OPT MODULE
OPT PREPROCESS


->/////////////////////////////////////////////////////////////////////////////
->////////////////////////////////////////////////////// External modules /////
->/////////////////////////////////////////////////////////////////////////////
MODULE 'muimaster' , 'libraries/mui'
MODULE 'tools/boopsi'
MODULE 'utility/tagitem' , 'utility/hooks'

MODULE '*Locale'


->/////////////////////////////////////////////////////////////////////////////
->//////////////////////////////////////////////////// Object definitions /////
->/////////////////////////////////////////////////////////////////////////////
EXPORT OBJECT app_arexx
	commands :	PTR TO mui_command
	error    :	hook
ENDOBJECT

EXPORT OBJECT app_display
	button_pressed          :	hook
ENDOBJECT

EXPORT OBJECT app_obj
	app                     :	PTR TO LONG
	wi_the_window           :	PTR TO LONG
	bt_put_constant_string  :	PTR TO LONG
	bt_put_variable         :	PTR TO LONG
	bt_return_id            :	PTR TO LONG
	bt_call_hook            :	PTR TO LONG
	tx_result               :	PTR TO LONG
	bt_quit                 :	PTR TO LONG
	stR_TX_result           :	PTR TO CHAR
ENDOBJECT


->/////////////////////////////////////////////////////////////////////////////
->////////////////////////////////////////////////// Constant definitions /////
->/////////////////////////////////////////////////////////////////////////////
EXPORT ENUM
	ID_BUTTON_PRESSED = 1


->/////////////////////////////////////////////////////////////////////////////
->/////////////////////////////////////////// Global variable definitions /////
->/////////////////////////////////////////////////////////////////////////////
EXPORT DEF string_var

EXPORT DEF cat : PTR TO catalog_DemoGenCodeE


->/////////////////////////////////////////////////////////////////////////////
->/////////// Creates one instance of one object or the whole application /////
->/////////////////////////////////////////////////////////////////////////////
PROC create( display : PTR TO app_display ,
             icon  = NIL ,
             arexx = NIL : PTR TO app_arexx ,
             menu  = NIL ) OF app_obj

	DEF grOUP_ROOT_0C , gr_grp_0 , gr_grp_1 , la_result , gr_grp_2

	self.stR_TX_result           := cat.msg_TX_result.getstr()

	self.bt_put_constant_string := SimpleButton( getMBstring( cat.msg_BT_put_constant_string.getstr() ) )

	self.bt_put_variable := SimpleButton( getMBstring( cat.msg_BT_put_variable.getstr() ) )

	self.bt_return_id := SimpleButton( getMBstring( cat.msg_BT_return_id.getstr() ) )

	self.bt_call_hook := SimpleButton( getMBstring( cat.msg_BT_call_hook.getstr() ) )

	la_result := Label( getMBstring( cat.msg_LA_result.getstr() ) )

	self.tx_result := TextObject ,
		MUIA_HelpNode , 'TX_result' ,
		MUIA_Background , MUII_TextBack ,
		MUIA_Frame , MUIV_Frame_Text ,
		MUIA_Text_Contents , self.stR_TX_result ,
		MUIA_Text_PreParse , '\el' ,
		MUIA_Text_SetMin , MUI_TRUE ,
	End

	gr_grp_1 := GroupObject ,
		MUIA_Group_Horiz , MUI_TRUE ,
		Child , la_result ,
		Child , self.tx_result ,
	End

	gr_grp_0 := GroupObject ,
		MUIA_Frame , MUIV_Frame_Group ,
		MUIA_FrameTitle , getMBstring( cat.msg_GR_grp_0Title.getstr() ) ,
		Child , self.bt_put_constant_string ,
		Child , self.bt_put_variable ,
		Child , self.bt_return_id ,
		Child , self.bt_call_hook ,
		Child , gr_grp_1 ,
	End

	self.bt_quit := SimpleButton( getMBstring( cat.msg_BT_quit.getstr() ) )

	gr_grp_2 := GroupObject ,
		Child , self.bt_quit ,
	End

	grOUP_ROOT_0C := GroupObject ,
		Child , gr_grp_0 ,
		Child , gr_grp_2 ,
	End

	self.wi_the_window := WindowObject ,
		MUIA_Window_Title , getMBstring( cat.msg_WI_the_window.getstr() ) ,
		MUIA_HelpNode , 'WI_the_window' ,
		MUIA_Window_ID , "0WIN" ,
		WindowContents , grOUP_ROOT_0C ,
	End

	self.app := ApplicationObject ,
		( IF icon THEN MUIA_Application_DiskObject ELSE TAG_IGNORE ) , icon ,
		( IF arexx THEN MUIA_Application_Commands ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.commands ELSE NIL ) ,
		( IF arexx THEN MUIA_Application_RexxHook ELSE TAG_IGNORE ) , ( IF arexx THEN arexx.error ELSE NIL ) ,
		( IF menu THEN MUIA_Application_Menu ELSE TAG_IGNORE ) , menu ,
		MUIA_Application_Author , 'Lionel Vintenat' ,
		MUIA_Application_Base , 'DEMOGENCODEE' ,
		MUIA_Application_Title , 'DemoGenCodeE' ,
		MUIA_Application_Version , '$VER: DemoGenCodeE 1.0 (01.09.94)' ,
		MUIA_Application_Copyright , getMBstring( cat.msg_AppCopyright.getstr() ) ,
		MUIA_Application_Description , getMBstring( cat.msg_AppDescription.getstr() ) ,
		SubWindow , self.wi_the_window ,
	End

ENDPROC self.app


->/////////////////////////////////////////////////////////////////////////////
->////////////////////////// Disposes the object or the whole application /////
->/////////////////////////////////////////////////////////////////////////////
PROC dispose() OF app_obj IS ( IF self.app THEN Mui_DisposeObject( self.app ) ELSE NIL )


->/////////////////////////////////////////////////////////////////////////////
->/////////////////////// Initializes all the notifications of one object /////
->/////////////////////////////////////////// or of the whole application /////
->/////////////////////////////////////////////////////////////////////////////
PROC init_notifications( display : PTR TO app_display ) OF app_obj

	domethod( self.bt_put_constant_string , [
		MUIM_Notify , MUIA_Pressed , FALSE ,
		self.tx_result ,
		3 ,
		MUIM_Set , MUIA_Text_Contents , getMBstring( cat.msg_BT_put_constant_stringNotify0.getstr() ) ] )

	domethod( self.bt_put_variable , [
		MUIM_Notify , MUIA_Pressed , FALSE ,
		self.tx_result ,
		3 ,
		MUIM_Set , MUIA_Text_Contents , string_var ] )

	domethod( self.bt_return_id , [
		MUIM_Notify , MUIA_Pressed , FALSE ,
		self.app ,
		2 ,
		MUIM_Application_ReturnID , ID_BUTTON_PRESSED ] )

	domethod( self.bt_call_hook , [
		MUIM_Notify , MUIA_Pressed , FALSE ,
		self.app ,
		2 ,
		MUIM_CallHook , display.button_pressed ] )

	domethod( self.bt_quit , [
		MUIM_Notify , MUIA_Pressed , FALSE ,
		self.app ,
		2 ,
		MUIM_Application_ReturnID , MUIV_Application_ReturnID_Quit ] )

	domethod( self.wi_the_window , [
		MUIM_Window_SetCycleChain , self.bt_put_constant_string ,
		self.bt_put_variable ,
		self.bt_return_id ,
		self.bt_call_hook ,
		self.bt_quit ,
		0 ] )

	set( self.wi_the_window ,MUIA_Window_Open , MUI_TRUE )

ENDPROC


->/////////////////////////////////////////////////////////////////////////////
->//////////// Special GetString() function for MUIBuilder generated code /////
->/////////////////////////////////////////////////////////////////////////////
PROC getMBstring( local_string : PTR TO CHAR ) RETURN ( IF local_string[ 1 ] = "\0" THEN ( local_string + 2 ) ELSE local_string )
