/*
 * Created on Dec 29, 2003
 *
 */

import java.awt.*;
import javax.swing.*;

import LumiSoft.UI.Controls.*;
import LumiSoft.UI.Controls.WOutlookBar.*;

/**
 * 
 */
public class wctrl_Main extends JPanel
{
	private WFrame wFrame = null;
	
	public wctrl_Main(ImageList imageList,ImageList imageListSmall)
	{	
		try{
			this.setLayout(new BorderLayout());
			
			WOutlookBar outlookBar = new WOutlookBar();
			outlookBar.setImageList(imageList);
			outlookBar.setImageListSmall(imageListSmall);
			outlookBar.setSize(200,400);
			outlookBar.addClickedListener(new OutlookBarListener(){
				public void ItemClicked(Object sender,Item item){
					OnOutlookBarItem_Clicked(item);			
				}
				
				public void BarClicked(Object sender,Bar item){}
			});
			
			outlookBar.getBars().Add("Controls demo");
			outlookBar.getBars().Add("Bar2 faslsfl fsööäöäsa");
			outlookBar.getBars().Add("Bar3");
			
			Bar bar = (Bar)outlookBar.getBars().get(0);
			bar.getItems().Add("Grid",0,"grid");
			bar.getItems().Add("WNumericEdit",0);
			bar.getItems().Add("Item 2 dgglkglaslk lkgalskl",0);
			bar.setItemsStyle(ItemsStyle.SmallIcon);
			
			Bar bar2 = (Bar)outlookBar.getBars().get(1);
			bar2.getItems().Add("Item 1",0);
			bar2.getItems().Add("Item 2 dgglkglaslk lkgalssagsggsgggggsgsg saggssg gsagsg kl",0);
			bar2.getItems().Add("Item 3 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 4 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 5 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 6 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 7 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 8 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 9 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 10 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 11 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 12 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 13 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 14 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 15 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 16 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 17 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 18 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 19 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 20 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 21 dgglkglaslk lkgalskl",0);
			bar2.getItems().Add("Item 22 last",0);
			bar2.setItemsStyle(ItemsStyle.SmallIcon);
			
			Bar bar3 = (Bar)outlookBar.getBars().get(2);
			bar3.getItems().Add("Item 1",0);
			bar3.getItems().Add("Item 2 dgglkglaslk lkgalskl",0);
			bar3.setItemsStyle(ItemsStyle.IconSelect);
			
			outlookBar.setActiveBar(bar);
			
					
			WContextMenu fileMenu = new WContextMenu(this);
			fileMenu.Add("Change Language");
			fileMenu.Add(true);
			fileMenu.Add("Exit");
			
			WToolBar toolbar = new WToolBar();
		//	toolbar.setSize(200,22);
			toolbar.setLocation(5,340);
			toolbar.setImageList(imageListSmall);
			toolbar.getItems().Add(0);
			toolbar.getItems().Add(0);
			toolbar.getItems().Add(true);
			toolbar.getItems().Add(0);
			((WToolBarItem)toolbar.getItems().get(0)).setMenu(fileMenu);
			
			wFrame = new WFrame();
			wFrame.setSize(400,200);
			wFrame.setLocation(5,270);
			wFrame.setToolBar(toolbar);
			wFrame.setControl(outlookBar);
			wFrame.setForm(new wctrl_Controls(imageList,imageListSmall));
		//	wFrame.setForm(new te());
		
			this.add(wFrame,BorderLayout.CENTER);
		}
		catch(Exception x){
			x.printStackTrace();
		}
	}
	
	private void OnOutlookBarItem_Clicked(Item item)
	{
		if(item.getTag() == null){
			return;
		}
		
		if(item.getText().equals("WNumericEdit")){			
			wFrame.setForm(new wctrl_WNumericEdit_demo());
		}
		else if(item.getTag().toString().equals("grid")){
			wFrame.setForm(new wfrm_Test_Grid());
		}
	}

}
