Esempio n. 1
0
void DockBase::SerializeLayout(Stream& s, bool deflay)
{
	CtrlRecord* record	= NULL;
	DockableCtrl* ctrl	= NULL;
	TreeCtrl& tree		= grouptab.grouptree;	
	String  name;
	int		panesize	= 0;
	int 	type 		= 0;
	int 	alignment	= 0;
	int 	state		= 0;
	int 	position	= 0;
	int 	id			= 0;
	int 	childcount	= 0;
	Size	childsize;
	
		if(s.IsStoring())
		{
			// Remove unused TabWindows (BugFix).
			RefreshTabWindowList();
			// Write Tabbing mode.
			s % tabsnested;
			// Write Widgets.
			// Write Docked (shown or hidden) and AutoHidden widgets.
			childcount = GetDockedWindowCount();
			s / childcount;
			if(childcount)
				for(int i = 0; i < childcount; i++)
				{
					ctrl = GetDockedWindowFromIndex(i);
					ASSERT(ctrl);
					ctrl->Serialize(s);
				}
			// Write PaneFrame sizes.
			for(int i = 0; i < 4; i++)  
			{
				panesize = GetPaneFrame(i).GetSize();
				s / panesize;
			}
			childcount = 0;
			int ctrlscount = ctrls.GetCount();
			// Write Floating Dockwindows.
			for(int i = 0; i < ctrlscount * 2; i++)
			{
				if(i < ctrlscount) childcount += GetCtrlRecordFromIndex(i)->ctrl->IsFloating() ? 1 : 0;
				if(i >= ctrlscount) 
				{
					if(i == ctrlscount) s / childcount;
					ctrl = GetCtrlRecordFromIndex(i - ctrlscount)->ctrl;
					ASSERT(ctrl);
					if(ctrl->IsFloating()) ctrl->Serialize(s);
				}
			}
			childcount = 0;
			// Write Floating TabWindows.
			int tabwindowcount = GetTabWindowCount();
			if(tabwindowcount)
				for(int i = 0; i < tabwindowcount * 2; i++)
				{
					if(i <  tabwindowcount) childcount += GetTabWindowFromIndex(i)->IsFloating() ? 1 : 0;
					if(i >= tabwindowcount)
					{
						if(i == tabwindowcount) s / childcount;
						TabWindow* tabwindow = GetTabWindowFromIndex(i - tabwindowcount);
						ASSERT(tabwindow);
						if(tabwindow->IsFloating()) tabwindow->Serialize(s);
					}
				}
		}

		if(s.IsLoading())
		{
			childcount = 0;
			// Close All widgets.
			for(int i = 0; i < GetTabWindowCount(); i++)	GetTabWindowFromIndex(i)->DetachAll();
			for(int i = 0; i < ctrls.GetCount(); i++) 		GetCtrlRecordFromIndex(i)->ctrl->Shut();
			// Remove unused TabWindows (BugFix).
			RefreshTabWindowList();
			// Read Tabbing Mode
			s % tabsnested;
			controlpanel.TabOptionNest <<= tabsnested;
			// Read Docked (shown or hidden) and AutoHidden widgets.
			s / childcount;
			if(childcount)
				for(int i = 0; i < childcount; i++)
				{
					s / type / id;
					if(type == DockableCtrl::TYPE_DOCKWINDOW)
						GetCtrlRecordFromId(id)->ctrl->Serialize(s);
					if(type == DockableCtrl::TYPE_TABWINDOW)
						GetPaneFrame(0).AddTabWindow()->Serialize(s);
				}
			// Read PaneFrame sizes.
			for(int i = 0; i < 4; i++)
			{
				s / panesize;
				GetPaneFrame(i).SetSize(panesize);
			}
			childcount = 0;
			s / childcount;
			if(childcount)
				for(int i = 0; i < childcount; i++)
				{
					s / type / id;
					GetCtrlRecordFromId(id)->ctrl->Serialize(s);
				}
			
			childcount = 0;
			s / childcount;
			if(childcount)
				for(int j = 0; j < childcount; j++)
				{
					s / type / id;
					TabWindow* tabwindow = GetPaneFrame(0).AddTabWindow();
					tabwindow->Serialize(s);
				}
		}		
		s.Close();
}
Esempio n. 2
0
void DockBase::RefreshPanel()
{
    if(!controlpanel.IsOpen() || !controlpanel.IsVisible()) return;
    listtab.list.Clear();
    for(int i = 0; i < GetCtrlRecords().GetCount(); i++) 
    {
        int 	alignment 	= 0;
        bool 	tabbed		= false;
        bool	floating	= false;
		DockableCtrl* ctrl 	= GetCtrlRecordFromIndex(i)->ctrl;
		if(ctrl->IsTabbed())
		{
			TabWindow* tabwindow = dynamic_cast<DockWindow*>(ctrl)->GetOwnerTab();
			if(tabwindow) 
			{
				alignment = tabwindow->GetBaseTab()->Alignment();
				floating = tabwindow->GetBaseTab()->IsAutoHidden();
				tabbed = true;
			}
		}
		else alignment = ctrl->Alignment();
		String a, s;
        switch(alignment)
        {
			case DockableCtrl::DOCK_LEFT:
				a = t_("LEFT");
                break;
			case DockableCtrl::DOCK_TOP:
                a = t_("TOP");
            	break;
            case DockableCtrl::DOCK_RIGHT:
                a = t_("RIGHT");
                break;
            case DockableCtrl::DOCK_BOTTOM:
                a = t_("BOTTOM");
                break;
            case DockableCtrl::DOCK_NONE:
                if(ctrl->IsFloating() || tabbed)
                a = t_("FLOATING");
                else
                a = t_("NONE");  	
                break;     
		}
        switch(ctrl->State())
        {
            case DockableCtrl::STATE_SHOW:
                s = t_("SHOWN");
                break;
            case DockableCtrl::STATE_HIDE:
                s = t_("HIDDEN");
                break;
            case DockableCtrl::STATE_AUTO:
                s = t_("AUTO HIDDEN");
           		break;
            case DockableCtrl::STATE_SHUT:
                s = t_("SHUT");
                break;
            case DockableCtrl::STATE_TABBED:
            	floating ?
            	s = t_("AUTO HIDDEN")
            	:
                s = t_("TABBED");
                break;
        }
  
 		listtab.list.Add(0, Format("%s",ctrl->GetLabel()), a, s, ctrl->Position());
		listtab.list.SetCtrl(i, 0, (panelicons.At(i))->SetImage(ctrl->GetIcon().IsNullInstance() ? 
                   DockCtrlImages::DefaultImage : ctrl->GetIcon()));
      }
   controlpanel.Refresh();
}