PRO palette_update,Data = Data

	COMPILE_OPT IDL2
    Tvlct, r, g, b, /Get
    data.oPalette->Setproperty, Red_Values = r, $
				   	Green_Values = g, Blue_Values = b
	data.oWindow->Draw, data.oScene

;	DrawInstance , data.oWindow , data.oScene
END
;+
;flow manage
;+
PRO sesMenuBar::FlowManage , type = type
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	; close cut image interface
	IF Obj_Valid(self.CutImage) THEN BEGIN
		Widget_Control , (self.CutImage).cBase , /Destroy
		self.CutImage->CloseFlow
		Obj_Destroy , self.CutImage
	ENDIF
	; close section interface
	IF Obj_Valid(self.PlotSection) THEN BEGIN
		Widget_Control , (self.PlotSection).cBase , /Destroy
		self.PlotSection->CloseFlow
		Obj_Destroy , self.PlotSection
	ENDIF
	; close show LQU interface
	IF Obj_Valid(self.ShowLQU) THEN BEGIN
		Widget_Control , (self.ShowLQU).cBase , /Destroy
		self.ShowLQU->CloseFlow
		Obj_Destroy , self.ShowLQU
	ENDIF
 	IF ~Keyword_Set(type) THEN BEGIN
		; close label interface
		Widget_Control,(osystem.lable).lablebase,map=0
		toolBar = oSystem.toolBar
		drawObjs = toolBar.objContainer->Get(/All, Count = dCount)
		FOR i=3, 7 DO drawObjs[i]->Recover
		drawObjs[3]->ButtonDown
	ENDIF
	toolBar = oSystem.toolBar
	IF Obj_Valid(toolBar.Magnifier) THEN BEGIN
		Widget_Control, (toolBar.Magnifier).cBase, /Destroy
		Obj_Destroy , (toolBar.Magnifier).mContainer
		Obj_Destroy , toolBar.Magnifier
	ENDIF
	self.CurrentName = ''

	Widget_Control,(oSystem.lable).lablebase,map=0
	(oSystem).opt_state=0

	oSystem.oWindow->Draw, oSystem.oScene

END
;+
;menu manage
;+
PRO sesMenuBar::MenuManage , type
	COMPILE_OPT IDL2
	menuButton = self.menuButton
	CASE type OF
		'begin':BEGIN
			temp = [2,3,4]
			FOR i = 0 , 2 DO BEGIN
				Widget_Control,menuButton[0,temp[i]],Sensitive = 0
			ENDFOR
			temp = [3,4,5,7,8]
			FOR i = 0 , 4 DO BEGIN
				Widget_Control,menuButton[1,temp[i]],Sensitive = 0
			ENDFOR
			FOR i = 1 , 9 DO BEGIN
				Widget_Control,menuButton[2,i],Sensitive = 0
			ENDFOR
			Widget_Control,menuButton[3,1],Sensitive = 0
		END
		'openhigh':BEGIN
			FOR i = 1 , 5 DO BEGIN
				Widget_Control,menuButton[0,i],Sensitive = 1
			ENDFOR
			FOR i = 1 , 8 DO BEGIN
				Widget_Control,menuButton[1,i],Sensitive = 1
			ENDFOR
			FOR i = 1 , 9 DO BEGIN
				Widget_Control,menuButton[2,i],Sensitive = 1
			ENDFOR
			temp = [5,6,8,9]
			FOR i = 0 , 3 DO BEGIN
				Widget_Control,menuButton[2,temp[i]],Sensitive = 0
			ENDFOR
			Widget_Control,menuButton[3,1],Sensitive = 1
		END
		'openlow':BEGIN
			FOR i = 1 , 5 DO BEGIN
				Widget_Control,menuButton[0,i],Sensitive = 1
			ENDFOR
			FOR i = 1 , 8 DO BEGIN
				Widget_Control,menuButton[1,i],Sensitive = 1
			ENDFOR
			Widget_Control,menuButton[1,7],Sensitive = 0

			FOR i = 1 , 9 DO BEGIN
				Widget_Control,menuButton[2,i],Sensitive = 1
			ENDFOR
			temp = [5,6,8,9]
			FOR i = 0 , 3 DO BEGIN
				Widget_Control,menuButton[2,temp[i]],Sensitive = 0
			ENDFOR
			Widget_Control,menuButton[2,3],Sensitive = 1
			Widget_Control,menuButton[3,1],Sensitive = 1
		END
		'openmulti':BEGIN
			FOR i = 1 , 5 DO BEGIN
				Widget_Control,menuButton[0,i],Sensitive = 1
			ENDFOR
			FOR i = 1 , 8 DO BEGIN
				Widget_Control,menuButton[1,i],Sensitive = 0
			ENDFOR
			temp = [1,2]
			FOR i = 0 , 1 DO BEGIN
				Widget_Control,menuButton[1,temp[i]],Sensitive = 1
			ENDFOR
			FOR i = 1 , 9 DO BEGIN
				Widget_Control,menuButton[2,i],Sensitive = 0
			ENDFOR
			Widget_Control,menuButton[3,1],Sensitive = 0
		END
	ELSE:
	ENDCASE
    self.CurrentName = ''
END

;+
;timer order data
;+
PRO sesMenuBar::TimerOrder , filename , fitData , Numbers , orderName , showTime
	COMPILE_OPT IDL2

	head = ''
	showTime = StrArr(Numbers)
	FOR i = 0 , Numbers-1 DO BEGIN
		fitData = Bytscl(ReadFitData(filename[i],fit_header))
		head = [head,sxpar(fit_header, 'T_START' )]
	ENDFOR
	oTemp = Where(head EQ 0 , count)
	IF count GE 2 THEN BEGIN
		showTime[0:Numbers-1] = 0
		orderName = filename
	ENDIF ELSE BEGIN
		head = head[1:*]
		timeArr = StrArr(N_Elements(head))
		FOR i = 0 , N_Elements(head)-1 DO BEGIN
			time = strsplit(head[i], ' ', /Extract)
	  		yy = strsplit(time[0], '-', /Extract)
			dd = strsplit(time[1], ':', /Extract)
			timeArr[i] = yy[0]+'_'+yy[1]+'_'+yy[2]+'_'+dd[0]+'_'+dd[1]+'_'+dd[2]+'_'+strtrim(String(i),2)
		ENDFOR
		newArr = timeArr[sort(timeArr)]
		number = IntArr(N_Elements(head))
		FOR i = 0 , N_Elements(head)-1 DO BEGIN
			yy = strsplit(newArr[i], '_', /Extract)
			number[i] = Fix(yy[6])
			showTime[i] = yy[0]+'-'+yy[1]+'-'+yy[2]+' '+yy[3]+':'+yy[4]+':'+yy[5]
		ENDFOR
		orderName = filename[number]
	ENDELSE
END
;+
;output image
;+
PRO sesMenuBar::SaveImage , type = type , event = event
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	ClassImage = oSystem.CurrentPro
	IF Obj_Valid(oSystem.CurrentPro) THEN BEGIN
		ClassImage.oView->GetProperty, Dimensions = viewDim , $
		                            Location = viewLoc   , $
		                            ViewPlane_Rect = viewPlane
		ClassName = Obj_Class(oSystem.CurrentPro)
		IF ClassName EQ 'SESMULTIIMAGE' THEN BEGIN
			(oSystem.CurrentPro).seleFrame->SetProperty,Hide = 1
			oSystem.oScene->Setproperty,Color = [255,255,255]
		ENDIF
		save_img = SnapScreen(oview=ClassImage.oView, xsize=viewDim[0], $
		                      ysize=viewDim[1], zoom_param= 1)

		IF ClassName EQ 'SESMULTIIMAGE' THEN BEGIN
			(oSystem.CurrentPro).seleFrame->SetProperty,Hide = 0
			(oSystem.CurrentPro).outerFrame->GetProperty,data = data
			range = [min(data[0,*]),max(data[0,*]) , $
			         min(data[1,*]),max(data[1,*])]
			oSystem.oScene->Setproperty,Color = [128,128,128]
			save_img = save_img[*,(range[0]-1):(range[1]+2) , $
			                      (range[2]-1):(range[3]+2)]
		ENDIF
	ENDIF
	CASE type OF
		'bmp':BEGIN
			fileName = Dialog_PickFile(Title = 'save as'        , $
		                     File   = 'test.bmp'        	, $
		                     Dialog_Parent = oSystem.mBase  , $
		                     Path   = oSystem.RootDir    	, $
		                     /OverWrite_Prompt				, $
		                     /Write							, $
		                     Filter = '*.bmp'   	    	)

			IF fileName EQ '' THEN Return
			Write_Bmp, fileName, Temporary(save_img), /RGB
		END
		'gif':BEGIN
			fileName = Dialog_PickFile(Title = 'save as'        , $
		                     File   = 'test.gif'        	, $
		                     Dialog_Parent = oSystem.mBase  , $
		                     Path   = oSystem.RootDir    	, $
		                     /OverWrite_Prompt				, $
		                     /Write							, $
		                     Filter = '*.gif'   	    	)

			IF fileName EQ '' THEN Return
			save_img = Color_Quan(save_img, 1, r, g, b)
	      	Write_Gif, filename, Temporary(save_img), r, g, b
		END
		'jpeg':BEGIN
			fileName = Dialog_PickFile(Title = 'save as'        , $
		                     File   = 'test.jpeg'        	, $
		                     Dialog_Parent = oSystem.mBase  , $
		                     Path   = oSystem.RootDir    	, $
		                     /OverWrite_Prompt				, $
		                     /Write							, $
		                     Filter = '*.jpeg'   	    	)

			IF fileName EQ '' THEN Return
			Write_Jpeg, fileName, Temporary(save_img), /True, Quality = 100
		END
		'png':BEGIN
			fileName = Dialog_PickFile(Title = 'save as'        , $
		                     File   = 'test.png'        	, $
		                     Dialog_Parent = oSystem.mBase  , $
		                     Path   = oSystem.RootDir    	, $
		                     /OverWrite_Prompt				, $
		                     /Write							, $
		                     Filter = '*.png'   	    	)

			IF fileName EQ '' THEN Return
			save_img = Color_Quan(save_img, 1, r, g, b)
	      	Write_Png, filename, Temporary(save_img), r, g, b
		END
		'tif':BEGIN
			fileName = Dialog_PickFile(Title = 'save as'        , $
		                     File   = 'test.tif'        	, $
		                     Dialog_Parent = oSystem.mBase  , $
		                     Path   = oSystem.RootDir    	, $
		                     /OverWrite_Prompt				, $
		                     /Write							, $
		                     Filter = '*.tif'   	    	)

			IF fileName EQ '' THEN Return
			Write_Tiff, filename, Reverse(save_img, 3)
		END
		'ps':BEGIN
			filename = 'test.ps'
			PS_Plotter,save_img,event,filename
		END

	ELSE:
	ENDCASE

END
;+
;copy image to clipboard
;+
PRO sesMenuBar::Clipboard
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	imageClass = oSystem.CurrentPro
	oSystem.oWindow->GetProperty, RESOLUTION = screenResolution
	imageClass.oView->GetProperty, Location=old_locs
	; Initialize clipboard destination object.
	Arr = ['SESSINGLEIMAGE','SESCHANGEIMAGE']
	temp = Where(Obj_Class(imageClass) EQ Arr,count)
	IF count NE 0 THEN BEGIN
		imageClass.oView->SetProperty, Location=[0,0]
		dimension = [imageClass.imageX, imageClass.imageY]*imageClass.zoom
	ENDIF ELSE BEGIN
		(oSystem.CurrentPro).outerFrame->GetProperty,data = data
		range = [min(data[0,*]),max(data[0,*]) , $
		         min(data[1,*]),max(data[1,*])]
		dimension = [((range[1]+3)-(range[0]-1)) , $
		             ((range[3]+3)-(range[2]-1))]
		imageClass.oView->SetProperty, Location=[(1-range[0]),(1-range[2])]
	ENDELSE
	oClipboard = OBJ_NEW('IDLgrClipboard'                  , $
	                      QUALITY = 2                      , $
	                      DIMENSIONS = dimension           , $
	                      RESOLUTION = screenResolution    , $
	                      GRAPHICS_TREE = imageClass.oView)

	oClipboard->Draw, vector=0, POSTSCRIPT=0

	oClipboard->SetProperty, GRAPHICS_TREE = OBJ_NEW()
	Obj_Destroy, oClipboard
	imageClass.oView->SetProperty, Location=old_locs


END
;+
;plot image
;+
PRO sesMenuBar::PlotImage
	COMPILE_OPT IDL2
	Obj_Destroy , self.plotImage
	self.plotImage = Obj_New('sesPlotImage'          , $
	                        oSystem = self.oSystem	   $
	                       )

END
;+
;match data for cartoon play
;+
PRO sesMenuBar::CartoonMatch
	COMPILE_OPT IDL2
	Obj_Destroy , self.CarMatch
	self.CarMatch = Obj_New('sesMatch'               , $
	                        oSystem = self.oSystem	   $
	                       )
END
;+
;Show L Q U data
;+
PRO sesMenuBar::ShowLQU
	COMPILE_OPT IDL2
	IF self.type EQ 'High' THEN BEGIN
		self->FlowManage
		Obj_Destroy , self.ShowLQU
		self.CurrentName = 'LQU'
		self.ShowLQU = Obj_New('sesLQU'                  , $
								mmValue = self.MinMaxXY  , $
		                        oSystem = self.oSystem	   $
		                       )
	ENDIF
END
;+
;Histogram
;+
PRO sesMenuBar::showHistogram
	COMPILE_OPT IDL2
	Obj_Destroy , self.showHistogram
	self.showHistogram = Obj_New('sesHistogram'              , $
                             oSystem = self.oSystem	   $
						    )
END
;+
;calibrat
;+
PRO sesMenuBar::calibrat
	COMPILE_OPT IDL2
	self->FlowManage
	Obj_Destroy , self.calibrat
	self.calibrat = Obj_New('sesCalibrat'              , $
	                         oSystem = self.oSystem	   $
	                       )
END
;+
;print
;+
PRO sesMenuBar::SetPrint
	COMPILE_OPT IDL2
	Obj_Destroy , self.PrintSetup
	self.PrintSetup = Obj_New('sesPrint'              , $
	                           oSystem = self.oSystem	   $
	                       )
END
;+
;play cartoon
;+
PRO sesMenuBar::PlayCartoon
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	Obj_Destroy , self.Cartoon
	self.Cartoon = Obj_New('sesCartoon'              , $
	                        oSystem = self.oSystem	   $
	                       )

END
;+
;add title
;+
PRO sesMenuBar::AddTitle
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	IF Obj_Valid(self.Title) THEN Return
	Obj_Destroy , self.Title
	self.Title = Obj_New('sesTitle'                 , $
                          oSystem = self.oSystem	   $
						)
END
;+
;add color bar and edit color bar
;+
PRO sesMenuBar::AddColorbar
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	Obj_Destroy , self.Colorbar
	self.CurrentName = 'Colorbar'
	self.Colorbar = Obj_New('sesColorbar'              , $
                             oSystem = self.oSystem	   $
						    )
END
;+
;cut image with mouse or input value
;+
PRO sesMenuBar::CutImage
	COMPILE_OPT IDL2
	self->FlowManage
	Obj_Destroy , self.CutImage
	self.CurrentName = 'CutImage'
	self.CutImage = Obj_New('sesCutout'              , $
                             oSystem = self.oSystem	   $
						    )
END
;+
;plot x range and y range value
;+
PRO sesMenuBar::PlotSection
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	self->FlowManage
	Obj_Destroy , self.PlotSection
	self.CurrentName = 'PlotXY'
	self.PlotSection = Obj_New('sesSection'              , $
                                oSystem = self.oSystem	   $
							  )
END
;+
;add contour
;+
PRO sesMenuBar::AddContour
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	className = Obj_Class(oSystem.CurrentPro)
	IF className EQ 'SESCHANGEIMAGE' THEN BEGIN
		MinMaxXY = (oSystem.rightMenu).MinMaxXY
	ENDIF ELSE BEGIN
		MinMaxXY = self.MinMaxXY
	ENDELSE
	Obj_Destroy , self.oContour
	self.oContour = Obj_New('sesContour'               , $
							 MinMaxXY = MinMaxXY       , $
							 oSystem = self.oSystem	     $
							)
END
;+
;add pallette
;+
PRO sesMenuBar::AddPallette
	COMPILE_OPT IDL2
	self->FlowManage
	oSystem = self.oSystem
	imageClass = oSystem.CurrentPro
	dataObj = {$
				oPalette	:	imageClass.oPalette	, $
				oWindow		:	oSystem.oWindow		, $
				oScene		:	oSystem.oScene		  }
	imageClass.oPalette->Getproperty, Red_Values = r, $
				   	     Green_Values = g, Blue_Values = b
	Tvlct, r, g, b
	Tvlct, r, g, b, /Get
	orgTabel = [[r],[g],[b]]
	XLoadct, /Modal, Group = OSystem.mBase	, $
			UpDateCallBack = 'palette_update', $
			UpDateCBData = dataObj, $
			use_current = 1       , $
			OrgTabel = orgTabel
    Tvlct, r, g, b, /Get
    imageClass.oPalette->Setproperty, Red_Values = r, $
				   	Green_Values = g, Blue_Values = b

	oSystem.oWindow->Draw, oSystem.oScene
	IF Obj_Valid(self.Colorbar) THEN BEGIN
		self.Colorbar->ChangeColor , r , g , b
	ENDIF

;	DrawInstance , oSystem.oWindow , oSystem.oScene

END
;+
;delete temp file
;+
PRO sesMenuBar::deleteFile
	COMPILE_OPT IDL2
	sep = (self.oSystem).sep
	FOR i = 0 , self.numbers-1 DO BEGIN
		deleFolder = (self.oSystem).tempDir+sep+'Data'+String(Strtrim(i+1,2))
		deleImage = deleFolder+sep+'Image'+String(Strtrim(i+1,2))+'.dat'
		deleCopy = deleFolder+sep+'copyImage'+String(Strtrim(i+1,2))+'.dat'
		deletext = deleFolder+sep+'text'+String(Strtrim(i+1,2))+'.ini'
		File_Delete, deletext, /Quiet
		File_Delete, deleImage, /Quiet
		File_Delete, deleCopy, /Quiet
		File_Delete, deleFolder, /Quiet
	ENDFOR
END
;+
;clean oview
;+
PRO sesMenuBar::CleanObject
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	IF Obj_Valid(self.singleImage) THEN BEGIN
		oSystem.oScene->Remove, (self.singleImage).oView
		Obj_Destroy, (self.singleImage).oView
	ENDIF
	IF Obj_Valid(self.multiImge) THEN BEGIN
		oSystem.oScene->Remove, (self.multiImge).oView
		Obj_Destroy, (self.multiImge).oView
	ENDIF
	IF Obj_Valid((oSystem.rightMenu).ChangeImage) THEN BEGIN
		oSystem.oScene->Remove, ((oSystem.rightMenu).ChangeImage).oView
		Obj_Destroy, ((oSystem.rightMenu).ChangeImage).oView
	ENDIF
	IF Obj_Valid(self.Colorbar) THEN BEGIN
		Obj_Destroy,self.Colorbar
	ENDIF
	Obj_Destroy , self.singleImage
	Obj_Destroy , self.multiImge
	Obj_Destroy , (oSystem.rightMenu).ChangeImage
	oSystem.oWindow->Draw, oSystem.oScene
END
;+
;open image and create calss to read data
;+
PRO sesMenuBar::OpenImage
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	sep = (oSystem.sep)
	self->FlowManage
	filter = ['*.fit','*.dat','*.fits','*.fts']
	fileName=Dialog_Pickfile(title='Please choose a fit file' , $
	                         filter=filter                    , $
	                         path=self.RootDir+sep+'data'	      , $
	                         /Multiple_Files )

	Numbers = N_Elements(fileName)
	oSystem.oWindow -> Draw, oSystem.oScene
	IF Numbers EQ 1 THEN BEGIN
	    IF (fileName NE '') THEN BEGIN
	    	self->CleanObject
			fitData = ReadFitData(filename[0],fit_header)
			seg= Strmid(File_BaseName(filename[0]), 0, 1)
			number = ['L','Q','U']
			temp = Where(seg EQ number , count)
			IF count NE 0 THEN BEGIN
				fitData = Swap_Endian(Temporary(fitData))
				newData=fitData*10000./Sxpar(fit_header,'CALIBRAT')
				self.MinMaxXY = [min(newData),max(newData)]
				self.type = 'High'
				self->MenuManage , 'openhigh'
				oSystem.toolBar->MenuManage , 'openhigh'
			ENDIF ELSE BEGIN
				self.type = 'Low'
				newData = Temporary(fitData)
				self.MinMaxXY = [min(newData),max(newData)]
				self->MenuManage , 'openlow'
				oSystem.toolBar->MenuManage , 'openlow'
			ENDELSE

	    	self.singleImage = Obj_New('sesSingleImage'                       , $
			                            oSystem = self.oSystem                , $
			                            image = Bytscl(Temporary(newData))    , $
			                            data = fitData                        , $
			                            head = fit_header             )
			Obj_Destroy,oSystem.CurrentPro
			oSystem.CurrentPro = self.singleImage
			Obj_Destroy , self.Title
			self->AddTitle
		ENDIF
	ENDIF
	IF Numbers GT 25 THEN BEGIN
		oSystem.oWindow -> Draw, oSystem.oScene
		status = Dialog_Message('files number out of range', Title = 'warn')
		Return
	ENDIF
	IF Numbers GE 2 THEN BEGIN
		IF (fileName[0] NE '') THEN BEGIN
			IF self.numbers NE 0 THEN BEGIN
				self->deleteFile
				self->CleanObject
			ENDIF
			oSystem.oProcess->mapBase , 1

			self->MenuManage , 'openmulti'
			oSystem.toolBar->MenuManage , 'openmulti'

			self->TimerOrder , filename , fitData , Numbers , orderName , showTime
			FOR i = 0 , Numbers-1 DO BEGIN
				fitData = ReadFitData(orderName[i],fit_header)
				seg= Strmid(File_BaseName(orderName[i]), 0, 1)
				number = ['L','Q','U']
				temp = Where(seg EQ number , count)
				IF count NE 0 THEN BEGIN
					fitData = Swap_Endian(Temporary(fitData))
					newData=fitData*10000./Sxpar(fit_header,'CALIBRAT')
					MinMaxXY = Double([min(fitData),max(fitData)])
				ENDIF ELSE BEGIN
					newData = Temporary(fitData)
					MinMaxXY = Double([min(newData),max(newData)])
				ENDELSE
				title = StrArr(6)
				content = ['CONTENT','WAVELENG','HSOS_NO','T_START','T_END','TIME_POS']
				FOR t = 0 , 5 DO BEGIN
					 name = sxpar(fit_header, content[t] )
					 title[t] = name
				ENDFOR
				imageDimension = Size(newData , /N_Dimensions )
				imageSize = Size(newData , /Dimensions)
				tempDir = (self.oSystem).tempDir+sep+'Data'+String(Strtrim(i+1,2))
				File_MKDir, tempDir
				Name = 'Image'+String(Strtrim(i+1,2))+'.dat'
				Copy  = 'copyImage'+String(Strtrim(i+1,2))+'.dat'
				textName = 'text'+String(Strtrim(i+1,2))+'.ini'
				(self.oSystem).oShmData->Create , tempDir, name , Copy          , $
												  textName = textName           , $
												  Data = Bytscl(Temporary(newData))   , $
				                                  DimX = imageSize[0]           , $
				                                  DimY = imageSize[1]           , $
				                                  DimZ = imageDimension         , $
				                                  title = title                 , $
				                                  seg = seg                     , $
				                                  MinMaxXY = MinMaxXY           , $
				                                  newName = showTime[i]

				oSystem.oProcess->DoProcess , (36/Numbers)+i+1
				self.OI = i
			ENDFOR
			IF (36/Numbers)+self.OI+1 LT 36 THEN BEGIN
				FOR i = (36-((36/Numbers)+self.OI)) , 35 DO BEGIN
					oSystem.oProcess->DoProcess , i
				ENDFOR
			ENDIF
			oSystem.oProcess->mapBase , 0
			self.multiImge = Obj_New('sesMultiImage'                           , $
									  Numbers = Numbers                        , $
									  tempDir = (self.oSystem).tempDir         , $
	                                  oSystem = self.oSystem	                 $
	                                )

			self.numbers = Numbers

			Obj_Destroy,oSystem.CurrentPro
			oSystem.CurrentPro = self.multiImge

		ENDIF
	ENDIF

END
;+
;create menu bar
;+
PRO sesMenuBar::Create
	COMPILE_OPT IDL2

	menuButton = LonArr(10,50)
	;menu bar name and uname
	menuValue = ['File','Tools','Layer','Annotate','Movie','Help']
	menuUName = ['sesMenu_file','sesMenu_tools','sesMenu_layer','sesMenu_label' , $
	             'sesMenu_cartoon','sesMenu_help']
	;'File' menu name and uname
    fileValue = ['Open','Save As...','Close','Print','Exit', $
                 'ps','gif','jpeg','png','tiff','bmp','copy to clipboard']
    fileUName = ['sesMenu_open','sesMenu_output','sesMenu_close','sesMenu_print','sesMenu_exit', $
                 'sesMenu_ps','sesMenu_gif','sesMenu_jpeg','sesMenu_png','sesMenu_tiff','sesMenu_bmp','sesMenu_CC']
    ;'Tools' menu name and uname
    toolValue = ['Calibrat','Transform Data','Cut Down','Pallette','Section','Plot','show LQU','Histogram']
    toolUName = ['sesMenu_calibrat','sesMenu_transform','sesMenu_cut','sesMenu_pallette' , $
                 'sesMenu_section','sesMenu_plot','sesMenu_LQU','sesMenu_Histogram']
    ;'Layer' menu name and uname
    layerValue = ['Contour','Colorbar','Title','Add','Edit','ReMove','Add','Edit','ReMove']
    layerUName = ['sesMenu_isoline','sesMenu_colorbar','sesMenu_title','sesMenu_add','sesMenu_edit','sesMenu_remove','sesMenu_addco','sesMenu_editco','sesMenu_removeco']
    ;'Label' menu name and uname
    labelValue = ['Annotate']
    labelUName = ['sesMenu_symbollabel']
    ;'Cartoon' menu name and uname
    cartoonValue = ['Movie']
    cartoonUName = ['sesMenu_movie']
    ;'Help' menu name and uname
    helpValue = ['OnLineHelp']
    helpUName = ['sesMenu_onlinehelp']

	; create first menu
	FOR i = 0 , 5 DO BEGIN
		menuButton[i,0] = Widget_Button(self.mainBaseBar           , $
										Value = menuValue[i]	   , $
										UName = menuUName[i]	   , $
										/Menu				         )
	ENDFOR
	;create 'file' menu
	separator = BytArr(20)
	menu = BytArr(20)
	separator[[1,2,3]] = 1
	menu[[1]] = 1
	FOR i = 0 , 4 DO BEGIN
		menuButton[0,i+1] = Widget_Button(menuButton[0,0]          , $
										  Value = fileValue[i]	   , $
										  UName = fileUName[i]     , $
										  separator = separator[i] , $
										  menu = menu[i]             $
		                                  )
	ENDFOR
	FOR i = 5 , 10 DO BEGIN
		menuButton[0,i+1] = Widget_Button(menuButton[0,2]          , $
										  Value = fileValue[i]	   , $
										  UName = fileUName[i]     , $
										  separator = separator[i] , $
										  menu = menu[i]             $
		                                  )
	ENDFOR

	menuButton[0,11] = Widget_Button(menuButton[0,2]            , $
									  Value = fileValue[11]	    , $
									  accelerator='Ctrl+C'      , $
									  UName = fileUName[11]     , $
									  separator = separator[11] , $
									  menu = menu[11]             $
	                                  )
	;create 'tools' menu
	separator[[1,2,3,4,6]] = 1
	menu[[1]] = 0
	FOR i = 0 , 7 DO BEGIN
		menuButton[1,i+1] = Widget_Button(menuButton[1,0]          , $
                                          Value = toolValue[i]     , $
                                          UName = toolUName[i]     , $
                                          separator = separator[i] , $
                                          menu = menu[i] 	         $
		                                 )
	ENDFOR
	menu[[0,1]] = 1
	;create 'layer' menu
	FOR i = 0 , 2 DO BEGIN
		menuButton[2,i+1] = Widget_Button(menuButton[2,0]          , $
		 								  Value = LayerValue[i]    , $
		 								  UName = LayerUName[i]    , $
										  separator = separator[i] , $
										  menu = menu[i]             $
										 )
	ENDFOR
	separator[[3,4,5]] = 1
	FOR i = 3 , 5 DO BEGIN
		menuButton[2,i+1] = Widget_Button(menuButton[2,1]          , $
										  Value = LayerValue[i]	   , $
										  UName = LayerUName[i]     , $
										  separator = separator[i] , $
										  menu = menu[i]             $
		                                  )
	ENDFOR
	separator[[6,7,8]] = 1
	FOR i = 6 , 8 DO BEGIN
		menuButton[2,i+1] = Widget_Button(menuButton[2,2]          , $
										  Value = LayerValue[i]	   , $
										  UName = LayerUName[i]     , $
										  separator = separator[i] , $
										  menu = menu[i]             $
		                                  )
	ENDFOR
	;create 'label' menu
	FOR i = 0 , 0 DO BEGIN
		menuButton[3,i+1] = Widget_Button(menuButton[3,0]          , $
										  Value = labelValue[i]  , $
										  UName = labelUName[i]    $
										 )
	ENDFOR
	;create 'cartoon' menu
	FOR i = 0 , 0 DO BEGIN
		menuButton[4,i+1] = Widget_Button(menuButton[4,0]          , $
										  Value = CartoonValue[i]  , $
										  UName = CartoonUName[i]    $
										 )
	ENDFOR
	;create 'help' menu
	FOR i = 0 , 0 DO BEGIN
		menuButton[5,i+1] = Widget_Button(menuButton[5,0]          , $
										  Value = helpValue[i]  , $
										  UName = helpUName[i]    $
										 )
	ENDFOR

	self.menuButton = menuButton
END
;+
;event manage
;+
PRO sesMenuBar::HandleEvent , UName , event = event
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	CASE UName OF
		'open':BEGIN
			self->OpenImage
		END
		'output':BEGIN
		END
		'close':BEGIN
			self->FlowManage
			self->MenuManage , 'begin'
			oSystem.toolBar->MenuManage , 'begin'
			IF Obj_Valid(self.Title) THEN BEGIN
				Obj_Destroy,self.Title
			ENDIF
			IF Obj_Valid(self.Colorbar) THEN BEGIN
				Obj_Destroy,self.Colorbar
			ENDIF
			IF Obj_Valid(oSystem.CurrentPro) THEN BEGIN
				Obj_Destroy,oSystem.CurrentPro
			ENDIF
			oSystem.oWindow -> Draw, oSystem.oScene
		END
		'set':BEGIN
		END
		'print':BEGIN
			self->SetPrint
		END
		'exit':BEGIN
			status = Dialog_Message('Exit SunEle?', Title = 'Warn', /Question)
			IF status EQ 'Yes'THEN Widget_Control, oSystem.mBase, /Destroy
		END
		'bmp':BEGIN
			self->SaveImage , type = 'bmp'
		END
		'gif':BEGIN
			self->SaveImage , type = 'gif'
		END
		'jpeg':BEGIN
			self->SaveImage , type = 'jpeg'
		END
		'png':BEGIN
			self->SaveImage , type = 'png'
		END
		'tiff':BEGIN
			self->SaveImage , type = 'tif'
		END
		'ps':BEGIN
			self->SaveImage , type = 'ps' , event = event
		END
		'CC':BEGIN
			self->Clipboard
		END
		'calibrat':BEGIN
			self->calibrat
		END
		'transform':BEGIN
			self->FlowManage
			mainBase = oSystem.mBase
			datatransform , mainBase , tBase
			self.tBase = tBase
		END
		'cut':BEGIN
			self->CutImage
		END
		'pallette':BEGIN
			self->AddPallette
		END
		'section':BEGIN
			self->PlotSection
		END
		'plot':BEGIN
			self->PlotImage
		END
		'LQU':BEGIN
			self->ShowLQU
		END
		'Histogram':BEGIN
			self->showHistogram
		END
		'match':BEGIN
			self->CartoonMatch
		END
		'isoline':BEGIN
		END
		'addco':BEGIN
			self->FlowManage
			menuButton = self.menuButton
			temp = [8,9]
			FOR i = 0 , 1 DO BEGIN
				Widget_Control,menuButton[2,temp[i]],Sensitive = 1
			ENDFOR
			self->AddColorbar
		END
		'editco':BEGIN
			self.Colorbar->Edit
		END
		'removeco':BEGIN
			menuButton = self.menuButton
			temp = [8,9]
			FOR i = 0 , 1 DO BEGIN
				Widget_Control,menuButton[2,temp[i]],Sensitive = 0
			ENDFOR
			self.CurrentName = ''
			self.Colorbar->Remove

		END
		'title':BEGIN
			self->AddTitle
		END
		'add':BEGIN
			menuButton = self.menuButton
			temp = [5,6]
			FOR i = 0 , 1 DO BEGIN
				Widget_Control,menuButton[2,temp[i]],Sensitive = 1
			ENDFOR
			self->AddContour
		END
		'edit':BEGIN
			self.oContour->CreateEditMenu
		END
		'remove':BEGIN
			menuButton = self.menuButton
			temp = [5,6]
			FOR i = 0 , 1 DO BEGIN
				Widget_Control,menuButton[2,temp[i]],Sensitive = 0
			ENDFOR
			self.oContour->Remove
		END
		'symbollabel':BEGIN
			self->FlowManage
			self.CurrentName = 'Label'
		 	osystem.lable->basemap
		 	osystem.opt_state=1
		END
		'movie':BEGIN
			self->FlowManage
			self->PlayCartoon
		END
		'onlinehelp':BEGIN
			sep = (self.oSystem).sep
			OnLine_Help, Book = self.rootDir+sep+'resource'+sep+'onlinehelp'+sep+'help.htm'
		END
	ELSE:
	ENDCASE
END
;+
;clean up
;+
PRO sesMenuBar::CleanUp
	COMPILE_OPT IDL2
	Obj_Destroy , self.singleImage
	Obj_Destroy , self.oShmData
	Obj_Destroy , self.multiImge
	Obj_Destroy , self.oContour
	Obj_Destroy , self.PlotSection
	Obj_Destroy , self.CutImage
	Obj_Destroy , self.Colorbar
	Obj_Destroy , self.Cartoon
	Obj_Destroy , self.Title
	Obj_Destroy , self.PrintSetup
	Obj_Destroy , self.calibrat
	Obj_Destroy , self.ShowLQU
	Obj_Destroy , self.showHistogram
	Obj_Destroy , self.CarMatch
	Obj_Destroy , self.plotImage

END
;+
;initialize
;+
FUNCTION sesMenuBar::Init , mBar    = mbar    , $
                            oSystem = oSystem
	COMPILE_OPT IDL2
	self.oSystem = oSystem
	self.mainBaseBar = mBar
	self.RootDir = oSystem.RootDir
	self->Create
	self->MenuManage , 'begin'
	Return,1
END
;+
;menu bar class name
;+
PRO sesMenuBar__Define
	COMPILE_OPT IDL2
	void = { sesMenuBar                              , $
	         ;system parameter
  			 menuButton          :  LonArr(10,50)    , $
  			 mainBaseBar         :	0                , $
  			 tBase               :  0L               , $
  			 RootDir             :  ''               , $
  			 numbers             :  0                , $
  			 OI                  :  0                , $
  			 CurrentName         :  ''               , $
  			 type                :  ''               , $
  			 MinMaxXY            :  [0.0,0.0]        , $
  			 ;system objct
  			 singleImage         :  Obj_New()        , $
  			 multiImge           :  Obj_New()        , $
  			 oShmData            :  Obj_New()        , $
  			 oContour            :  Obj_New()        , $
  			 PlotSection         :  Obj_New()        , $
  			 CutImage            :  Obj_New()        , $
  			 Colorbar            :  Obj_New()        , $
  			 Cartoon             :  Obj_New()        , $
  			 Title               :  Obj_New()        , $
  			 PrintSetup          :  Obj_New()        , $
  			 calibrat            :  Obj_New()        , $
  			 ShowLQU             :  Obj_New()        , $
  			 CarMatch            :  Obj_New()        , $
  			 plotImage           :  Obj_New()        , $
  			 showHistogram       :  Obj_New()        , $
             oSystem             :  Obj_New()          $
	       }

END