	/* This procedure creates one app object */
PROC create_app( icon )

	DEF app , wi_main , gr_default_tools , lv_default_tools
	DEF stR_old_def_tool , po_new_def_tool , stR_PO_new_def_tool
	DEF lv_new_def_tools , bt_delete_def_tool , gr_paths , lv_paths , pa_path
	DEF stR_PA_path , bt_delete_path , tx_info , bt_go , bt_stop
	DEF bt_save_prefs , bt_about , bt_quit

	DEF tmp_object : PTR TO obj_app

	DEF a4_tmp
	DEF display_def_tool_hook : PTR TO hook
	DEF compare_def_tool_hook : PTR TO hook
	DEF str_obj_hook : PTR TO hook
	DEF obj_str_hook : PTR TO hook

	DEF arexx_commands : PTR TO mui_command
	DEF number_paths_hook : PTR TO hook
	DEF number_default_tools_hook : PTR TO hook
	DEF add_path_hook : PTR TO hook
	DEF add_default_tool_hook : PTR TO hook
	DEF delete_path_hook : PTR TO hook
	DEF delete_default_tool_hook : PTR TO hook
	DEF get_path_hook : PTR TO hook
	DEF get_old_default_tool_hook : PTR TO hook
	DEF get_new_default_tool_hook : PTR TO hook
	DEF save_prefs_hook : PTR TO hook
	DEF go_hook : PTR TO hook
	DEF loose_modifications_hook : PTR TO hook
	DEF arexx_error_hook : PTR TO hook

	MOVE.L	A4 , a4_tmp

	display_def_tool_hook := New( SIZEOF hook )
	display_def_tool_hook.entry := {display_def_tool}
	display_def_tool_hook.data := a4_tmp

	compare_def_tool_hook := New( SIZEOF hook )
	compare_def_tool_hook.entry := {compare_def_tool}
	compare_def_tool_hook.data := a4_tmp

	str_obj_hook := New( SIZEOF hook )
	str_obj_hook.entry := {open_new_def_tools_list}
	str_obj_hook.data := a4_tmp

	obj_str_hook := New( SIZEOF hook )
	obj_str_hook.entry := {close_new_def_tools_list}
	obj_str_hook.data := a4_tmp

	number_paths_hook := New( SIZEOF hook )
	number_paths_hook.entry := {number_paths}
	number_paths_hook.data := a4_tmp

	number_default_tools_hook := New( SIZEOF hook )
	number_default_tools_hook.entry := {number_default_tools}
	number_default_tools_hook.data := a4_tmp

	add_path_hook := New( SIZEOF hook )
	add_path_hook.entry := {arexx_add_path}
	add_path_hook.data := a4_tmp

	add_default_tool_hook := New( SIZEOF hook )
	add_default_tool_hook.entry := {arexx_add_default_tool}
	add_default_tool_hook.data := a4_tmp

	delete_path_hook := New( SIZEOF hook )
	delete_path_hook.entry := {arexx_delete_path}
	delete_path_hook.data := a4_tmp

	delete_default_tool_hook := New( SIZEOF hook )
	delete_default_tool_hook.entry := {arexx_delete_default_tool}
	delete_default_tool_hook.data := a4_tmp

	get_path_hook := New( SIZEOF hook )
	get_path_hook.entry := {get_path}
	get_path_hook.data := a4_tmp

	get_old_default_tool_hook := New( SIZEOF hook )
	get_old_default_tool_hook.entry := {get_old_default_tool}
	get_old_default_tool_hook.data := a4_tmp

	get_new_default_tool_hook := New( SIZEOF hook )
	get_new_default_tool_hook.entry := {get_new_default_tool}
	get_new_default_tool_hook.data := a4_tmp

	save_prefs_hook := New( SIZEOF hook )
	save_prefs_hook.entry := {arexx_save_prefs}
	save_prefs_hook.data := a4_tmp

	go_hook := New( SIZEOF hook )
	go_hook.entry := {arexx_go}
	go_hook.data := a4_tmp

	loose_modifications_hook := New( SIZEOF hook )
	loose_modifications_hook.entry := {loose_modifications}
	loose_modifications_hook.data := a4_tmp

	arexx_error_hook := New( SIZEOF hook )
	arexx_error_hook.entry := {arexx_error}
	arexx_error_hook.data := a4_tmp

	arexx_commands := New( ( SIZEOF mui_command ) * 13 )
	arexx_commands := [	'number_paths' , '' , 0 , number_paths_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'number_default_tools' , '' , 0 , number_default_tools_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'add_path' , 'PATH/A' , 1 , add_path_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'add_default_tool' , 'OLD/A,NEW/A' , 2 , add_default_tool_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'delete_path' , 'PATH/N/A' , 1 , delete_path_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'delete_default_tool' , 'DEFAULT_TOOL=DT/N/A' , 1 , delete_default_tool_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'get_path' , 'PATH/N/A' , 1 , get_path_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'get_old_default_tool' , 'OLD_DEFAULT_TOOL=ODT/N/A' , 1 , get_old_default_tool_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'get_new_default_tool' , 'NEW_DEFAULT_TOOL=NDT/N/A' , 1 , get_new_default_tool_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'save_prefs' , '' , 0 , save_prefs_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'go' , '' , 0 , go_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						'loose_modifications' , '' , 0 , loose_modifications_hook ,
																			NIL , NIL , NIL , NIL ,NIL ,
						NIL , NIL , NIL , NIL ,
																			NIL , NIL , NIL , NIL ,NIL ] : mui_command

	IF ( tmp_object := New( SIZEOF obj_app ) ) = NIL THEN RETURN NIL

	app := ApplicationObject ,
		MUIA_Application_Author , 'Lionel Vintenat' ,
		MUIA_Application_Base , 'DEFT_II' ,
		MUIA_Application_Title , 'Deft II' ,
		MUIA_Application_Version , '$VER: Deft_II 1.0 (24.07.94)' ,
		MUIA_Application_Copyright , '© 1994, Lionel Vintenat' ,
		MUIA_Application_Description , get_DeftII_string( msg_AppDescription ) ,
		MUIA_Application_DiskObject , icon ,
		MUIA_Application_Commands , arexx_commands ,
		MUIA_Application_RexxHook , arexx_error_hook ,
		MUIA_HelpFile, 'Deft II.guide',
		SubWindow , wi_main := WindowObject ,
			MUIA_Window_Title , get_DeftII_string( msg_WI_main ) ,
			MUIA_Window_ID , MAKE_ID( "0" , "W" , "I" , "N" ) ,
			MUIA_Window_AppWindow , MUI_TRUE ,
			WindowContents , GroupObject ,
				Child , GroupObject ,
					MUIA_Group_Horiz , MUI_TRUE ,
					Child , gr_default_tools := GroupObject ,
						MUIA_Weight , 200 ,
						GroupFrameT( get_DeftII_string( msg_GR_default_tools ) ) ,
						MUIA_HelpNode , 'gr_default_tools' ,
						Child , lv_default_tools := ListviewObject ,
							MUIA_Listview_DoubleClick , MUI_TRUE ,
							MUIA_Listview_List , ListObject ,
								InputListFrame ,
								MUIA_HelpNode , 'lv_default_tools' ,
								MUIA_List_Format , 'DELTA=10,' ,
								MUIA_List_DisplayHook , display_def_tool_hook ,
								MUIA_List_CompareHook , compare_def_tool_hook ,
							End ,
						End ,
						Child , GroupObject ,
							MUIA_Group_Columns , 2 ,
							Child , Label( get_DeftII_string( msg_LA_old_def_tool ) ) ,
							Child , stR_old_def_tool := StringObject ,
								StringFrame ,
								MUIA_HelpNode , 'stR_old_def_tool' ,
								MUIA_String_MaxLen , 256 ,
								MUIA_String_Format , 0 ,
							End ,
							Child , Label( get_DeftII_string( msg_LA_new_def_tool ) ) ,
							Child , po_new_def_tool := PopobjectObject ,
								MUIA_HelpNode , 'po_new_def_tool' ,
								MUIA_Popstring_String , stR_PO_new_def_tool := StringMUI( '' , 256 ) ,
								MUIA_Popstring_Button , PopButton( MUII_PopUp ) ,
								MUIA_Popobject_Light , MUI_TRUE ,
								MUIA_Popobject_Follow , MUI_TRUE ,
								MUIA_Popobject_Volatile , MUI_TRUE ,
								MUIA_Popobject_StrObjHook , str_obj_hook ,
								MUIA_Popobject_ObjStrHook , obj_str_hook ,
								MUIA_Popobject_Object , lv_new_def_tools := ListviewObject ,
									MUIA_Listview_DoubleClick , MUI_TRUE ,
									MUIA_Listview_List , ListObject ,
										InputListFrame ,
									End ,
								End ,
							End ,
						End ,
						Child , bt_delete_def_tool := et_key_button( get_DeftII_string( msg_BT_delete_def_tool ) ) ,
					End ,
					Child , gr_paths := GroupObject ,
						GroupFrameT( get_DeftII_string( msg_GR_paths ) ) ,
						MUIA_HelpNode , 'gr_paths' ,
						Child , lv_paths := ListviewObject ,
							MUIA_Listview_DoubleClick , MUI_TRUE ,
							MUIA_Listview_List , ListObject ,
								InputListFrame ,
								MUIA_HelpNode , 'lv_paths' ,
								MUIA_List_ConstructHook , MUIV_List_ConstructHook_String ,
								MUIA_List_DestructHook , MUIV_List_DestructHook_String ,
							End ,
						End ,
						Child , pa_path := PopaslObject ,
							MUIA_HelpNode , 'pa_path' ,
							MUIA_Popasl_Type , 0 ,
							MUIA_Popstring_String , stR_PA_path := StringMUI( '' , 256 ) ,
							MUIA_Popstring_Button , PopButton( MUII_PopDrawer ) ,
							ASLFR_DRAWERSONLY , TRUE ,
						End ,
						Child , bt_delete_path := et_key_button( get_DeftII_string( msg_BT_delete_path ) ) ,
					End ,
				End ,
				Child , GroupObject ,
					MUIA_Group_Horiz , MUI_TRUE ,
					Child , Label( get_DeftII_string( msg_LA_info ) ) ,
					Child , tx_info := TextObject ,
						MUIA_Background , 128 ,
						MUIA_Text_Contents , get_DeftII_string( msg_TX_info ) ,
						MUIA_Text_SetMax , 0 ,
						MUIA_Text_SetMin , 1 ,
						MUIA_Frame , 3 ,
						MUIA_HelpNode , 'tx_info' ,
					End ,
				End ,
				Child , GroupObject ,
					GroupFrameT( get_DeftII_string( msg_GR_controls ) ) ,
					MUIA_HelpNode , 'gr_controls' ,
					MUIA_Group_Horiz , MUI_TRUE ,
					MUIA_Group_SameWidth , MUI_TRUE ,
					Child , bt_go := et_key_button( get_DeftII_string( msg_BT_go ) ) ,
					Child , bt_stop := et_key_button( get_DeftII_string( msg_BT_stop ) ) ,
					Child , bt_save_prefs := et_key_button( get_DeftII_string( msg_BT_save_prefs ) ) ,
					Child , bt_about := et_key_button( get_DeftII_string( msg_BT_about ) ) ,
					Child , bt_quit := et_key_button( get_DeftII_string( msg_BT_quit ) ) ,
				End ,
			End ,
		End ,
	End

	tmp_object.app                 := app
	tmp_object.wi_main             := wi_main
	tmp_object.gr_default_tools    := gr_default_tools
	tmp_object.lv_default_tools    := lv_default_tools
	tmp_object.stR_old_def_tool    := stR_old_def_tool
	tmp_object.po_new_def_tool     := po_new_def_tool
	tmp_object.stR_PO_new_def_tool := stR_PO_new_def_tool
	tmp_object.lv_new_def_tools    := lv_new_def_tools
	tmp_object.bt_delete_def_tool  := bt_delete_def_tool
	tmp_object.gr_paths            := gr_paths
	tmp_object.lv_paths            := lv_paths
	tmp_object.pa_path             := pa_path
	tmp_object.stR_PA_path         := stR_PA_path
	tmp_object.bt_delete_path      := bt_delete_path
	tmp_object.tx_info             := tx_info
	tmp_object.bt_go               := bt_go
	tmp_object.bt_stop             := bt_stop
	tmp_object.bt_save_prefs       := bt_save_prefs
	tmp_object.bt_about            := bt_about
	tmp_object.bt_quit             := bt_quit

	IF tmp_object.app = NIL
		Dispose( tmp_object )
		RETURN NIL
	ENDIF


ENDPROC tmp_object


	/* This procedure deletes one app object */
PROC dispose_app( tmp_object : PTR TO obj_app )

	Mui_DisposeObject( tmp_object.app )
	Dispose( tmp_object )

ENDPROC


	/* ExTended KeyButton function */
PROC et_key_button( text : PTR TO CHAR ) RETURN KeyButton( ( text + 3 ), text[ 1 ] )


	/* DoMethod() function */
PROC doMethod( obj : PTR TO object , msg : PTR TO msg )

	DEF h : PTR TO hook , o : PTR TO object , dispatcher

	IF obj
		o := obj-SIZEOF object		/* instance data is to negative offset */
		h := o.class
		dispatcher := h.entry		/* get dispatcher from hook in iclass */
		MOVEA.L h,A0
		MOVEA.L msg,A1
		MOVEA.L obj,A2			/* probably should use CallHookPkt, but the */
		MOVEA.L dispatcher,A3		/*   original code (DoMethodA()) doesn't. */
		JSR (A3)			/* call classDispatcher() */
		MOVE.L D0,o
		RETURN o
	ENDIF

ENDPROC NIL
