indexing
	description: "List der Battle.net-Server"
	author: "Daniel Jacobi"
	date: "$Date: 2003/10/09 14:16:25 $"
	revision: "$Revision: 1.6 $"

class
	CHECK_SERVER

inherit
	WEL_LIST_VIEW
		redefine
			make,
			on_right_button_down,
			on_left_button_double_click,
			on_lvn_itemchanged
		end

	APPLICATION_IDS
		export
			{NONE} all
		end		
		
	WEL_REGISTRY_ACCESS_MODE
		export
			{NONE} all
		end

create
	make

feature {NONE} -- Initialization

	make (a_parent: WEL_WINDOW; a_x, a_y, a_width, a_height, an_id: INTEGER) is
			-- Initialize `Current'.
		local
			spalte					: WEL_LIST_VIEW_COLUMN
		do
 			{WEL_LIST_VIEW} Precursor (a_parent, a_x, a_y, a_width, a_height, an_id)

			-- Style
			set_style(Ws_visible + Ws_child + Ws_group + Ws_tabstop + Ws_border + Ws_clipchildren	
						+ Lvs_showselalways+ Lvs_singlesel + Lvs_report)
			set_extended_view_style(Lvs_ex_fullrowselect + Lvs_ex_gridlines)
			
			-- Spalten
			create spalte.make_with_attributes(Lvcf_text, 50, Lvcfmt_center, "Name")
			append_column(spalte)
			create spalte.make_with_attributes(Lvcf_text, 50, Lvcfmt_center, "D")
			append_column(spalte)
			create spalte.make_with_attributes(Lvcf_text, 50, Lvcfmt_center, "Zone")
			append_column(spalte)
			create spalte.make_with_attributes(Lvcf_text, 50, Lvcfmt_center, "Server")
			append_column(spalte)
			
			set_column_format(1, Lvcfmt_center)
			set_column_format(2, Lvcfmt_center)

			create rightclick_menu.make_by_id (Idm_mainframe)
			rightclick_menu := rightclick_menu.popup_menu(2)

			fenster ?= a_parent
		end
		
feature {NONE} -- Messages

	on_right_button_down (keys, x_pos, y_pos: INTEGER) is
			-- Handle right Mousbutton Events
		do
			Precursor (keys, x_pos, y_pos)
				
			rightclick_menu.show_track (absolute_x + x_pos, absolute_y  + y_pos, fenster)
		end

	on_left_button_double_click (keys, x_pos, y_pos: INTEGER) is
			-- Handle left Mousbutton Events
		do
			if selected_count > 0 then
				fenster.send_command (Idm_server_edit)
			end
		end
		
	on_lvn_itemchanged (info: WEL_NM_LIST_VIEW) is
			-- An item has changed.
		do
			Precursor (info) 
			set_item_availability
		end
		
feature {ANY} -- Access

	set_item_availability is
			-- en-/disable einige schaltfläche
		do
			if selected_count > 0 then
				rightclick_menu.enable_item (Idm_server_default)
				rightclick_menu.enable_item (Idm_server_edit)
				rightclick_menu.enable_item (Idm_server_delete)
				fenster.set_availability(Idm_server_edit, true)
				fenster.set_availability(Idm_server_delete, true)
				fenster.set_availability(Idm_server_default, true)
			else
				rightclick_menu.disable_item (Idm_server_default)
				rightclick_menu.disable_item (Idm_server_edit)
				rightclick_menu.disable_item (Idm_server_delete)
				fenster.set_availability(Idm_server_edit, false)
				fenster.set_availability(Idm_server_delete, false)
				fenster.set_availability(Idm_server_default, false)
			end
		
		end
		

	insert_server(bnl: BNET_SERVER_LIST) is
			-- insert Server to List
		local
			i			: INTEGER
			elem		: BNET_SERVER
			an_item		: WEL_LIST_VIEW_ITEM
			tmp			: STRING
		do
			reset_content
			fenster.set_availability(Idm_server_edit, false)
			fenster.set_availability(Idm_server_delete, false)

			from 
				i := 1
				create tmp.make_empty
			until
				i > bnl.count
			loop
				elem := bnl @ i

				create an_item.make
				an_item.set_text (elem.get_name)
				an_item.set_iitem (i-1)
				insert_item(an_item)

				if bnl.get_default = i then 
					set_cell_text (1, i-1, "X")
				end

				tmp.wipe_out
				tmp.append_integer(elem.get_zone)
				set_cell_text (2, i-1, tmp)
				set_cell_text (3, i-1, elem.get_url)

				i := i + 1;
			end
			fenster.set_availability (Idm_file_get, true)
			fenster.set_availability (Idm_server_add, true)
			fenster.set_availability (Idm_server_reset, true)

			rightclick_menu.enable_item (Idm_server_add)
			rightclick_menu.enable_item (Idm_server_deleteall)
			rightclick_menu.enable_item (Idm_server_reset)
		end

feature {NONE} -- Implementation

	fenster: MAIN_WINDOW
	
	rightclick_menu: WEL_MENU

end -- class CHECK_SERVER
