void COXDockTabCtrl::RemoveTab(CControlBar* pBar)
{
	// If there are not tabs just exit
	if (GetItemCount() == 0)
		return;

	// If there is only one other tab left we need to remove it as well
	if (m_pSizeDockBar->GetSizeControlBarCount(pBar) == 1)
	{
		COXSizeControlBar* pOther = m_pSizeDockBar->GetFirstDockedSizeControlBar(pBar);
		
		int iOtherIndex = FindTab(pOther);
		DeleteItem(iOtherIndex);
		pOther->GetDockingFrame()->ShowControlBar(pOther, TRUE, TRUE);
	}

	// Remove this tab
	int iIndex = FindTab(pBar);
	DeleteItem(iIndex);

	if (GetItemCount() > 1)
	{
		// Set the current selection to the previous tab
		if (iIndex != 0)
			SetCurSel(iIndex - 1);
		else
			SetCurSel(0);
		ShowSelectedTab();
	}
}
void LMSImportChannelMapDialog::LoadMapping(wxCommandEvent& event)
{
    wxFileDialog dlg(this);
    if (dlg.ShowModal() == wxID_OK) {
        for (int x = 0; x <  modelNames.size(); x++) {
            ModelsChoice->Append(modelNames[x]);
        }
        wxFileInputStream input(dlg.GetPath());
        wxTextInputStream text(input, "\t");
        MapByStrand->SetValue("true" == text.ReadLine());
        int count = wxAtoi(text.ReadLine());
        modelNames.clear();
        for (int x = 0; x < count; x++) {
            std::string mn = text.ReadLine().ToStdString();
            int idx = ModelsChoice->FindString(mn);
            if (idx == wxNOT_FOUND) {
                wxMessageBox("Model " + mn + " not part of sequence.  Not mapping channels to this model.", "", wxICON_WARNING | wxOK , this);
            } else {
                ModelsChoice->Delete(idx);
                modelNames.push_back(mn);
            }
        }
        if (MapByStrand->GetValue()) {
            SetupByStrand();
        } else {
            SetupByNode();
        }
        wxString line = text.ReadLine();
        int r = 0;
        while (line != "") {

            wxString model = FindTab(line);
            wxString strand = FindTab(line);
            wxString node = FindTab(line);
            wxString mapping = FindTab(line);
            xlColor color(FindTab(line));

            if (std::find(modelNames.begin(), modelNames.end(), model.ToStdString()) != modelNames.end()) {
                while (model != ChannelMapGrid->GetCellValue(r, 0)
                       && r < ChannelMapGrid->GetNumberRows()) {
                    r++;
                }

                if (model != ChannelMapGrid->GetCellValue(r, 0)
                    || strand != ChannelMapGrid->GetCellValue(r, 1)
                    || node !=  ChannelMapGrid->GetCellValue(r, 2)) {
                    wxMessageBox(model + "/"+strand+"/"+node+ " not found.  Has the models changed?", "", wxICON_WARNING | wxOK , this);
                } else {
                    ChannelMapGrid->SetCellValue(r, 3, mapping);
                    ChannelMapGrid->SetCellBackgroundColour(r, 4, color.asWxColor());
                }
                r++;
            }
            line = text.ReadLine();
        }
    }
}
Example #3
0
// Advances the selection, generation page selection events
void SLNotebook::AdvanceSelection(bool forward)
{
	if (GetPageCount() <= 1)
		return;
	int currentSelection = GetSelection();
	wxAuiTabCtrl* tabCtrl = 0;
	int idx = -1;

	if(!FindTab(GetPage(currentSelection), &tabCtrl, &idx))
		return;

	if(!tabCtrl || idx < 0)
		return;

	wxWindow* page = 0;
	size_t maxPages = tabCtrl->GetPageCount();

	forward?idx++:idx--;

	if(idx < 0)
		idx = maxPages - 1;

	if ((size_t)idx < maxPages)
		page = tabCtrl->GetPage(idx).window;

	if (!page && maxPages > 0)
		page = tabCtrl->GetPage(0).window;

	if(page)
	{
		currentSelection = GetPageIndex(page);
		SetSelection(currentSelection);
	}
}
// Inserts the given control bar as a new tab
void COXDockTabCtrl::InsertTab(CControlBar* pBar, int iIndex, BOOL bShowSelectedTab)
{
	// If this is the only control bar in the dock bar do nothing
	int iSizeControlBarCount = m_pSizeDockBar->GetSizeControlBarCount(pBar);
	if (iSizeControlBarCount == 0)
		return;

	// Add a tab for all other size control bars that are docked but not tabbed

	int i = 0;
	for (i = 0; i < m_pSizeDockBar->m_arrBars.GetSize(); i++)
	{
		COXSizeControlBar* pSizeBar = DYNAMIC_DOWNCAST(COXSizeControlBar, m_pSizeDockBar->GetDockedControlBar(i));
		if (pSizeBar != NULL && pSizeBar != pBar && FindTab(pSizeBar) == -1)
		{
			CString strTextOther;
			pSizeBar->GetWindowText(strTextOther);

			TCITEM tciOther;
			tciOther.mask = TCIF_TEXT | TCIF_PARAM;
			tciOther.pszText = strTextOther.GetBuffer(strTextOther.GetLength());
			tciOther.lParam = (LPARAM) pSizeBar;
		
			//Check added for visibility so that hidden control
			//bars don't get shown - Nish - Feb 15th 2005
			if(pSizeBar->IsWindowVisible())
				InsertItem(0, &tciOther);
		}
	}

	// Insert this control bar to the tab control
	CString strText;
	pBar->GetWindowText(strText);

	TCITEM tci;
	tci.mask = TCIF_TEXT | TCIF_PARAM;
	tci.pszText = strText.GetBuffer(strText.GetLength());
	tci.lParam = (LPARAM) pBar;

	InsertItem(iIndex, &tci);
	SetCurSel(iIndex);

	// Reshresh the tab control
	m_pSizeDockBar->PositionTabCtrl();

	if (bShowSelectedTab)
		ShowSelectedTab();
	else
	{
		int iSelected = GetCurSel();
		for (i = 0; i < GetItemCount(); i++)
		{
			CControlBar* pBar = GetBar(i);
			if (iSelected != i)
				pBar->GetDockingFrame()->ShowControlBar(pBar, FALSE, TRUE); // hide
		}
	}
}
Example #5
0
void FindTab(huffnode_t *tmp,int len,unsigned int bits)
{
	if(!tmp)
		Sys_Error("no huff node");
	if (tmp->zero)
	{
		if(!tmp->one)
			Sys_Error("no one in node");
		if(len>=32)
			Sys_Error("compression screwd");
		FindTab(tmp->zero,len+1,bits<<1);
		FindTab(tmp->one,len+1,(bits<<1)|1);
		return;
	}
	HuffLookup[tmp->val].len=len;
	HuffLookup[tmp->val].bits=bits;
	return;
}
Example #6
0
wxAuiTabCtrl* cbAuiNotebook::GetTabCtrl(wxWindow *page)
{
    if (page)
    {
        wxAuiTabCtrl *tabCtrl = nullptr;
        int idx;
        if (!FindTab(page, &tabCtrl, &idx))
            return nullptr;
        return tabCtrl;
    }
    else
        return GetActiveTabCtrl();
}
void
JXTabGroup::HandleDNDHere
	(
	const JPoint&	pt,
	const JXWidget*	source
	)
{
	JIndex i;
	JRect r;
	if (FindTab(pt, &i, &r))
		{
		ShowTab(i);
		}
}
Example #8
0
void tpanelnotebook::FillWindowLayout(unsigned int mainframeindex) {
	wxAuiPaneInfoArray &all_panes = m_mgr.GetAllPanes();
	size_t pane_count = all_panes.GetCount();

	size_t pagecount = GetPageCount();
	for (size_t i = 0; i < pagecount; ++i) {
		tpanelparentwin_nt *tppw = dynamic_cast<tpanelparentwin_nt*>(GetPage(i));
		if (!tppw) continue;

		wxAuiTabCtrl* tc;
		int tabindex;
		if (!FindTab(tppw, &tc, &tabindex)) continue;

		wxWindow *tabframe = GetTabFrameFromTabCtrl(tc);
		if (!tabframe) continue;

		unsigned int splitindex = 0;
		bool found = false;
		for (size_t j = 0; j < pane_count; ++j) {
			if (all_panes.Item(j).name == wxT("dummy")) {
				continue;
			}
			if (all_panes.Item(j).window == tabframe) {
				found = true;
				break;
			} else {
				splitindex++;
			}
		}
		if (!found) continue;

		ad.twinlayout.emplace_back();
		twin_layout_desc &twld = ad.twinlayout.back();
		twld.mainframeindex = mainframeindex;
		twld.splitindex = splitindex;
		twld.tabindex = tabindex;
		auto tp = tppw->pimpl()->tp_base;
		twld.tpautos = tp->tpautos;
		twld.tpudcautos = tp->tpudcautos;
		twld.name = tp->name;
		twld.dispname = tp->dispname;
		twld.flags = tp->flags;
		twld.intersect_flags = tppw->pimpl()->intersect_flags;
		twld.tppw_flags = tppw->pimpl()->tppw_flags & TPPWF::DB_SAVE_MASK;
	}
}
Example #9
0
void cbAuiNotebook::UpdateTabControlsArray()
{
    cbAuiTabCtrlArray saveTabCtrls = m_TabCtrls;
    m_TabCtrls.Clear();
    // first get all tab-controls
    const size_t tab_Count = GetPageCount();
    for (size_t i = 0; i < tab_Count; ++i)
    {
        wxAuiTabCtrl* tabCtrl = nullptr;
        int idx = -1;
        if (FindTab(GetPage(i), &tabCtrl, &idx))
        {
            if (tabCtrl && m_TabCtrls.Index(tabCtrl) == wxNOT_FOUND)
                m_TabCtrls.Add(tabCtrl);
        }
        else
            continue;
    }
    bool needEventRebind = m_TabCtrls.GetCount() != saveTabCtrls.GetCount();
    if (!needEventRebind)
    {
        for (size_t i = 0; i < m_TabCtrls.GetCount(); ++i)
        {
            if (saveTabCtrls.Index(m_TabCtrls[i]) == wxNOT_FOUND)
            {
                needEventRebind = true;
                break;
            }
        }
    }
    if (needEventRebind)
    {
        ResetTabCtrlEvents();
    }
    // make sure the active page is valid and shown
    for (size_t i = 0; i < m_TabCtrls.GetCount(); ++i)
    {
        int pageCount = m_TabCtrls[i]->GetPageCount();
        if (m_TabCtrls[i]->GetActivePage() < 0 && pageCount > 0)
             m_TabCtrls[i]->SetActivePage((size_t)0);
        if (m_TabCtrls[i]->GetActivePage() >= pageCount && pageCount > 0)
             m_TabCtrls[i]->SetActivePage(pageCount - 1);
        m_TabCtrls[i]->DoShowHide();
    }
}
void
JXTabGroup::HandleMouseHere
	(
	const JPoint&			pt,
	const JXKeyModifiers&	modifiers
	)
{
	JIndex i;
	JRect r;
	JBoolean found = FindTab(pt, &i, &r);

	if (found && i != itsMouseIndex)
		{
		itsMouseIndex = i;
		Refresh();
		}
	else if (!found && itsMouseIndex > 0)
		{
		HandleMouseLeave();
		}
}
bool wxAuiNotebookEx::SetPageText(size_t page_idx, const wxString& text)
{
    // Basically identical to the AUI one, but not calling Update
    if (page_idx >= m_tabs.GetPageCount())
        return false;

    // update our own tab catalog
    wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx);
    page_info.caption = text;

    // update what's on screen
    wxAuiTabCtrl* ctrl;
    int ctrl_idx;
    if (FindTab(page_info.window, &ctrl, &ctrl_idx)) {
        wxAuiNotebookPage& info = ctrl->GetPage(ctrl_idx);
        info.caption = text;
        ctrl->Refresh();
    }

    return true;
}
Example #12
0
int cbAuiNotebook::GetTabPositionFromIndex(int index)
{
    if (GetPageCount() <= 0)
        return wxNOT_FOUND;

    UpdateTabControlsArray();

    wxAuiTabCtrl* tabCtrl = nullptr;
    int idx = -1;

    if (!FindTab(GetPage(index), &tabCtrl, &idx))
        return wxNOT_FOUND;

    if (!tabCtrl || idx < 0)
        return wxNOT_FOUND;

    int indexOffset = 0;
    wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes();
    const size_t pane_count = all_panes.GetCount();
    for (size_t i = 0; i < pane_count; ++i)
    {
        wxAuiPaneInfo& pane = all_panes[i];
        if (pane.name == wxT("dummy"))
            continue;

        if (pane.window == GetTabFrameFromTabCtrl(tabCtrl))
            break;

        for (size_t j = 0; j < m_TabCtrls.GetCount(); ++j)
        {
            if (pane.window == GetTabFrameFromTabCtrl(m_TabCtrls[j]))
            {
                indexOffset += m_TabCtrls[j]->GetPageCount();
                break;
            }
        }
    }
    return idx + indexOffset;
}
Example #13
0
static void BuildTree (const float *freq)
{
	float	min1, min2;
	int	i, j, minat1, minat2;
	huffnode_t	*work[256];
	huffnode_t	*tmp;

	HuffMemBase = malloc(512 * sizeof(huffnode_t));
	if (!HuffMemBase)
		Sys_Error("Failed allocating memory for HuffTree");
	memset(HuffMemBase, 0, 512 * sizeof(huffnode_t));
	tmp = (huffnode_t *) HuffMemBase;

	for (i = 0; i < 256; tmp++, i++)
	{
		tmp->val = (unsigned char)i;
		tmp->freq = freq[i];
		tmp->zero = NULL;
		tmp->one = NULL;
		HuffLookup[i].len = 0;
		work[i] = tmp;
	}

	for (i = 0; i < 255; tmp++, i++)
	{
		minat1 = -1;
		minat2 = -1;
		min1 = 1E30;
		min2 = 1E30;

		for (j = 0; j < 256; j++)
		{
			if (!work[j])
				continue;
			if (work[j]->freq < min1)
			{
				minat2 = minat1;
				min2 = min1;
				minat1 = j;
				min1 = work[j]->freq;
			}
			else if (work[j]->freq < min2)
			{
				minat2 = j;
				min2 = work[j]->freq;
			}
		}
		if (minat1 < 0)
			Sys_Error("minat1: %d", minat1);
		if (minat2 < 0)
			Sys_Error("minat2: %d", minat2);
		tmp->zero = work[minat2];
		tmp->one = work[minat1];
		tmp->freq = work[minat2]->freq + work[minat1]->freq;
		tmp->val = 0xff;
		work[minat1] = tmp;
		work[minat2] = NULL;
	}

	HuffTree = --tmp; // last incrementation in the loop above wasn't used
	FindTab (HuffTree, 0, 0);

#if _DEBUG_HUFFMAN
	for (i = 0; i < 256; i++)
	{
		if (!HuffLookup[i].len && HuffLookup[i].len <= 32)
		{
		//	HuffPrintf("%d %d %2X\n", HuffLookup[i].len, HuffLookup[i].bits, i);
			Sys_Error("bad frequency table");
		}
	}
#endif	/* _DEBUG_HUFFMAN */
}
Example #14
0
bool eAuiNotebook::LoadPerspective(const wxString& layout) {
	// Remove all tab ctrls (but still keep them in main index)
	const size_t tab_count = m_tabs.GetPageCount();
	for (size_t i = 0; i < tab_count; ++i) {
		wxWindow* wnd = m_tabs.GetWindowFromIdx(i);

		// find out which onscreen tab ctrl owns this tab
		wxAuiTabCtrl* ctrl;
		int ctrl_idx;
		if (!FindTab(wnd, &ctrl, &ctrl_idx))
			return false;

		// remove the tab from ctrl
		if (!ctrl->RemovePage(wnd))
			return false;
	}
	RemoveEmptyTabFrames();

	size_t sel_page = 0;
	
	wxString tabs = layout.BeforeFirst(wxT('@'));
	while (1)
    {
		const wxString tab_part = tabs.BeforeFirst(wxT('|'));
		
		// if the string is empty, we're done parsing
        if (tab_part.empty())
            break;

		// Get pane name
		const wxString pane_name = tab_part.BeforeFirst(wxT('='));

		// create a new tab frame
		wxTabFrame* new_tabs = new wxTabFrame;
		new_tabs->m_tabs = new wxAuiTabCtrl(this,
											m_tab_id_counter++,
											wxDefaultPosition,
											wxDefaultSize,
											wxNO_BORDER|wxWANTS_CHARS);
		new_tabs->m_tabs->SetArtProvider(m_tabs.GetArtProvider()->Clone());
		new_tabs->SetTabCtrlHeight(m_tab_ctrl_height);
		new_tabs->m_tabs->SetFlags(m_flags);
		wxAuiTabCtrl *dest_tabs = new_tabs->m_tabs;

		// create a pane info structure with the information
		// about where the pane should be added
		wxAuiPaneInfo pane_info = wxAuiPaneInfo().Name(pane_name).Bottom().CaptionVisible(false);
		m_mgr.AddPane(new_tabs, pane_info);

		// Get list of tab id's and move them to pane
		wxString tab_list = tab_part.AfterFirst(wxT('='));
		while(1) {
			wxString tab = tab_list.BeforeFirst(wxT(','));
			if (tab.empty()) break;
			tab_list = tab_list.AfterFirst(wxT(','));

			// Check if this page has an 'active' marker
			const wxChar c = tab[0];
			if (c == wxT('+') || c == wxT('*')) {
				tab = tab.Mid(1); 
			}

			const size_t tab_idx = wxAtoi(tab.c_str());
			if (tab_idx >= GetPageCount()) continue;

			// Move tab to pane
			wxAuiNotebookPage& page = m_tabs.GetPage(tab_idx);
			const size_t newpage_idx = dest_tabs->GetPageCount();
			dest_tabs->InsertPage(page.window, page, newpage_idx);

			if (c == wxT('+')) dest_tabs->SetActivePage(newpage_idx);
			else if ( c == wxT('*')) sel_page = tab_idx;
		}
		dest_tabs->DoShowHide();

		tabs = tabs.AfterFirst(wxT('|'));
	}
	
	// Load the frame perspective
	const wxString frames = layout.AfterFirst(wxT('@'));
	m_mgr.LoadPerspective(frames);

	// Force refresh of selection
	m_curpage = -1;
	SetSelection(sel_page);

	return true;
}
void
JXTabGroup::HandleMouseDown
	(
	const JPoint&			pt,
	const JXMouseButton		button,
	const JSize				clickCount,
	const JXButtonStates&	buttonStates,
	const JXKeyModifiers&	modifiers
	)
{
	itsDragAction = kInvalidClick;

	if (button == kJXLeftButton && itsScrollUpRect.Contains(pt))
		{
		if (itsCanScrollUpFlag && itsFirstDrawIndex > 1)	// avoid left click when arrow disabled
			{
			itsDragAction         = kScrollUp;
			itsScrollUpPushedFlag = kJTrue;
			itsFirstDrawIndex--;
			Refresh();
			ScrollWait(kInitialScrollDelay);
			itsScrollUpPushedFlag = kJFalse;		// ignore first HandleMouseDrag()
			}
		}
	else if (button == kJXLeftButton && itsScrollDownRect.Contains(pt))
		{
		if (itsCanScrollDownFlag && itsFirstDrawIndex < GetTabCount())	// avoid left click when arrow disabled
			{
			itsDragAction           = kScrollDown;
			itsScrollDownPushedFlag = kJTrue;
			itsFirstDrawIndex++;
			Refresh();
			ScrollWait(kInitialScrollDelay);
			itsScrollDownPushedFlag = kJFalse;		// ignore first HandleMouseDrag()
			}
		}
	else if (button == kJXLeftButton &&
			 itsMouseIndex > 0 && itsCloseRect.Contains(pt))
		{
		itsDragAction      = kClose;
		itsClosePushedFlag = kJTrue;
		Refresh();
		}
	else if (button == kJXLeftButton)
		{
		JIndex i;
		JRect r;
		if (FindTab(pt, &i, &r))
			{
			ShowTab(i);
			}
		}
	else if (button == kJXRightButton)
		{
		CreateContextMenu();
		itsContextMenu->PopUp(this, pt, buttonStates, modifiers);
		}
	else
		{
		ScrollForWheel(button, modifiers);
		}
}
Example #16
0
bool cbAuiNotebook::LoadPerspective(const wxString& layout, bool mergeLayouts)
{
    if (layout.IsEmpty())
        return false;

    wxString tabs = layout.BeforeFirst (wxT ('@') );
    // Remove all tab ctrls (but still keep them in main index)
    const size_t tab_count = m_tabs.GetPageCount();
    for (size_t i = 0; i < tab_count; ++i)
    {
        // only remove tabs that are in the layout-string, do not touch others,
        // so the layout of an already loaded workspace or project will not get destroyed, if the
        // current layout did not know the tab. The layout file which is loaded last takes precedence,
        // if there are two or more layout strings containing the actual tab.
        if ( tabs.Find( UniqueIdFromTooltip(GetPageToolTip(i)) ) < 0 )
            continue;

        wxWindow* wnd = m_tabs.GetWindowFromIdx (i);

        // find out which onscreen tab ctrl owns this tab
        wxAuiTabCtrl* ctrl;
        int ctrl_idx;
        if ( !FindTab(wnd, &ctrl, &ctrl_idx) )
            return false;

        // remove the tab from ctrl
        if ( !ctrl->RemovePage(wnd) )
            return false;
    }
    RemoveEmptyTabFrames();
    wxString currentLayout;
    if (mergeLayouts)
    {
        currentLayout = m_mgr.SavePerspective();
        wxString tempLayout;
        while (!currentLayout.empty())
        {
            if ( currentLayout.BeforeFirst('|').StartsWith(_("layout2")) ||
                 currentLayout.BeforeFirst('|').StartsWith(_("name=dummy")) )
            {
                currentLayout = currentLayout.AfterFirst(('|'));
                currentLayout.Trim();
                currentLayout.Trim(true);
            }
            else
            {
                wxString pane_part = currentLayout.BeforeFirst('|');
                pane_part.Trim();
                pane_part.Trim(true);
                if (!pane_part.empty())
                    tempLayout += pane_part + wxT("|");

                currentLayout = currentLayout.AfterFirst('|');
                currentLayout.Trim();
                currentLayout.Trim(true);
            }
        }
        currentLayout = tempLayout;
        if (currentLayout.empty())
            mergeLayouts = false;
    }

    size_t sel_page = 0;
    int active_tab = 0;
    bool found = false;

    wxString frames = layout.AfterFirst (wxT ('@') );
    // if we load an additional project to an exiting layout, the first new tab always goes into a new frame
    bool firstTabInCtrl =! currentLayout.empty();
    // This creates a new tabframe if none exists; a workaround, because we can not directly access
    // the needed wxTabFrame class, because it is not exported.
    // This also takes care of all needed pane-info
    wxAuiTabCtrl* dest_tabs = GetActiveTabCtrl();
    while (1)
    {
        const wxString tab_part = tabs.BeforeFirst(wxT('|'));

        // if the string is empty, we're done parsing
        if (tab_part.empty())
            break;

        // Get pane name
        wxString pane_name = tab_part.BeforeFirst(wxT('='));

        // create a new tab frame
#if wxCHECK_VERSION(3, 0, 0)
        m_curPage = -1;
#else
        m_curpage = -1;
#endif

        // Get list of tab id's and move them to pane
        wxString tab_list = tab_part.AfterFirst(wxT('='));
        while (1)
        {
            wxString tab = tab_list.BeforeFirst(wxT(','));
            wxString name = tab.AfterFirst(wxT(';'));
            tab = tab.BeforeFirst(wxT(';'));

            if (tab.empty())
                break;
            tab_list = tab_list.AfterFirst(wxT(','));

            // Check if this page has an 'active' marker
            const wxChar c = tab[0];
            if (c == wxT('+') || c == wxT('*'))
                tab = tab.Mid(1);

            // Move tab to pane
            const int index_in_m_tabs = GetTabIndexFromTooltip(name);
            if (index_in_m_tabs < 0)
                continue;

            wxAuiNotebookPage& page = m_tabs.GetPage(index_in_m_tabs);

            // save the actual active tab, because it will be set to 0 after a Split()
            active_tab = dest_tabs->GetActivePage();
            const size_t newpage_idx = dest_tabs->GetPageCount();
            dest_tabs->InsertPage(page.window, page, newpage_idx);

            if (c == wxT('+'))
                dest_tabs->SetActivePage(newpage_idx);
            else if (c == wxT('*'))
                sel_page = index_in_m_tabs;

            // If we should be the first tab in a tab-ctrl we switch to the next existing tab,
            // or create a new one  by calling Split() and update the dest_tabs accordingly.
            if (firstTabInCtrl)
            {
                int nextIndex = m_TabCtrls.Index(dest_tabs) + 1;
                if (nextIndex == 0 || nextIndex >= static_cast<int>(m_TabCtrls.GetCount()))
                {
                    Split(index_in_m_tabs, wxRIGHT);
                    // reset the active tab, because a Split() set it to zero
                    dest_tabs->SetActivePage(active_tab);
                    dest_tabs = GetActiveTabCtrl();
                }
                else
                    dest_tabs = m_TabCtrls.Item(nextIndex);
            }
            // Change the pane name to the one we have stored in the layout-string.
            wxAuiPaneInfo& pane = m_mgr.GetPane( GetTabFrameFromTabCtrl(dest_tabs) );
            if (pane.name != pane_name)
            {
                tab.Replace(pane_name, pane.name);
                frames.Replace(pane_name, pane.name);
                pane_name = pane.name;
            }
            firstTabInCtrl = false;
            found = true;
        }
        // We come here after at least one tabctrl is filled, so the next tab should go in a new one
        firstTabInCtrl = true;

        tabs = tabs.AfterFirst(wxT('|'));
    }

    // Check for windows not readded to the notebook and add the at the end.
    for (size_t i = 0; i < tab_count; ++i)
    {
        wxAuiNotebookPage& page = m_tabs.GetPage(i);

        // find out which onscreen tab ctrl owns this tab
        // if none then add it to the last used tabctrl
        wxAuiTabCtrl* ctrl;
        int ctrl_idx;
        if ( !FindTab(page.window, &ctrl, &ctrl_idx) )
        {
            const size_t newpage_idx = dest_tabs->GetPageCount();
            dest_tabs->InsertPage (page.window, page, newpage_idx);
        }

    }

    if (mergeLayouts)
    {
        wxRegEx reDockSize(_T("(dock_size[()0-9,]+=)[0-9]+"));
        const wxString replacement(wxT("\\1-1"));
        // Make a centered frame left docked
        frames.Replace(wxString::Format(wxT("dock_size(%d"), wxAUI_DOCK_CENTER), wxString::Format(wxT("dock_size(%d"), wxAUI_DOCK_LEFT));
        frames.Replace(wxString::Format(wxT("dir=%d"), wxAUI_DOCK_CENTER), wxString::Format(wxT("dir=%d"), wxAUI_DOCK_LEFT));
        if (reDockSize.Matches(frames))
            reDockSize.ReplaceAll(&frames,replacement);
        if (reDockSize.Matches(currentLayout))
            reDockSize.ReplaceAll(&currentLayout,replacement);
        while (!currentLayout.empty())
        {
            wxString pane_part = currentLayout.BeforeFirst('|');
            pane_part.Trim();
            pane_part.Trim(true);
            if (!pane_part.empty())
                frames += pane_part + wxT("|");
            currentLayout = currentLayout.AfterFirst('|');
            currentLayout.Trim();
            currentLayout.Trim(true);
        }
    }

    if (found)
        m_mgr.LoadPerspective(frames);
    RemoveEmptyTabFrames();

    // Force refresh of selection
#if wxCHECK_VERSION(3, 0, 0)
    m_curPage = -1;
#else
    m_curpage = -1;
#endif
    SetSelection(sel_page);

    UpdateTabControlsArray();
    return true;
}
Example #17
0
void BuildTree(float *freq)
{
	float min1,min2;
	int i,j,minat1,minat2;
	huffnode_t *work[256];	
	huffnode_t *tmp;	
	for (i=0;i<256;i++)
	{
		work[i]=malloc(sizeof(huffnode_t));
		work[i]->val=(unsigned char)i;
		work[i]->freq=freq[i];
		work[i]->zero=0;
		work[i]->one=0;
		HuffLookup[i].len=0;
	}
	for (i=0;i<255;i++)
	{
		minat1=-1;
		minat2=-1;
		min1=1E30;
		min2=1E30;
		for (j=0;j<256;j++)
		{
			if (!work[j])
				continue;
			if (work[j]->freq<min1)
			{
				minat2=minat1;
				min2=min1;
				minat1=j;
				min1=work[j]->freq;
			}
			else if (work[j]->freq<min2)
			{
				minat2=j;
				min2=work[j]->freq;
			}
		}
		if (minat1<0)
			Sys_Error("minatl: %f",minat1);
		if (minat2<0)
			Sys_Error("minat2: %f",minat2);
		tmp=malloc(sizeof(huffnode_t));
		tmp->zero=work[minat2];
		tmp->one=work[minat1];
		tmp->freq=work[minat2]->freq+work[minat1]->freq;
		tmp->val=0xff;
		work[minat1]=tmp;
		work[minat2]=0;
	}		
	HuffTree=tmp;
	FindTab(HuffTree,0,0);
#if _DEBUG
	for (i=0;i<256;i++)
	{
		if(!HuffLookup[i].len&&HuffLookup[i].len<=32)
			Sys_Error("bad frequency table");
//		CON_Printf("%d %d %2X\n", HuffLookup[i].len, HuffLookup[i].bits, i);
	}
#endif
}
void LMSImportChannelMapDialog::LoadMapping(wxCommandEvent& event)
{
    bool strandwarning = false;
    bool modelwarning = false;
    if (_dirty)
    {
        if (wxMessageBox("Are you sure you dont want to save your changes for future imports?", "Are you sure?", wxYES_NO | wxCENTER, this) == wxNO)
        {
            return;
        }
    }

    wxFileDialog dlg(this);
    if (dlg.ShowModal() == wxID_OK) {
        for (size_t x = 0; x <  modelNames.size(); x++) {
            ModelsChoice->Append(modelNames[x]);
        }
        ChannelMapGrid->BeginBatch();
        wxFileInputStream input(dlg.GetPath());
        wxTextInputStream text(input, "\t");
        MapByStrand->SetValue("true" == text.ReadLine());
        int count = wxAtoi(text.ReadLine());
        modelNames.clear();
        for (int x = 0; x < count; x++) {
            std::string mn = text.ReadLine().ToStdString();
            int idx = ModelsChoice->FindString(mn);
            if (idx == wxNOT_FOUND) {
                //wxMessageBox("Model " + mn + " not part of sequence.  Not mapping channels to this model.", "", wxICON_WARNING | wxOK , this);
                if (!modelwarning)
                {
                    if (wxMessageBox("Model " + mn + " not part of sequence.  Not mapping channels to this model. Do you want to see future occurences of this error during this import?", "", wxICON_WARNING | wxYES_NO, this) == wxNO)
                    {
                        modelwarning = true;
                    }
                }
            } else {
                ModelsChoice->Delete(idx);
                modelNames.push_back(mn);
            }
        }
        if (MapByStrand->GetValue()) {
            SetupByStrand();
        } else {
            SetupByNode();
        }
        wxString line = text.ReadLine();
        int r = 0;
        while (line != "") {

            wxString model = FindTab(line);
            wxString strand = FindTab(line);
            wxString node = FindTab(line);
            wxString mapping = FindTab(line);
            xlColor color(FindTab(line));

            Element *modelEl = mSequenceElements->GetElement(model.ToStdString());
            if (modelEl == nullptr && allowAddModels) {
                modelEl = mSequenceElements->AddElement(model.ToStdString(), "model", false, false, false, false);
                modelEl->AddEffectLayer();
            }
            if (modelEl != nullptr) {
                while (model != ChannelMapGrid->GetCellValue(r, 0)
                       && r < ChannelMapGrid->GetNumberRows()) {
                    r++;
                }

                if (model != ChannelMapGrid->GetCellValue(r, 0)
                    || strand != ChannelMapGrid->GetCellValue(r, 1)
                    || node !=  ChannelMapGrid->GetCellValue(r, 2)) {
                    if (!strandwarning)
                    {
                        if (wxMessageBox(model + "/" + strand + "/" + node + " not found.  Has the models changed? Do you want to see future occurences of this error during this import?", "", wxICON_WARNING | wxYES_NO, this) == wxNO)
                        {
                            strandwarning = true;
                        }
                    }
                } else {
                    ChannelMapGrid->SetCellValue(r, 3, mapping);
                    ChannelMapGrid->SetCellBackgroundColour(r, 4, color.asWxColor());
                }
                r++;
            }
            line = text.ReadLine();
        }
        ChannelMapGrid->EndBatch();
        _dirty = false;
    }
}