bool wxHeaderCtrlBase::ShowCustomizeDialog()
{
#if wxUSE_REARRANGECTRL
    // prepare the data for showing the dialog
    wxArrayInt order = GetColumnsOrder();

    const unsigned count = GetColumnCount();

    // notice that titles are always in the index order, they will be shown
    // rearranged according to the display order in the dialog
    wxArrayString titles;
    titles.reserve(count);
    for ( unsigned n = 0; n < count; n++ )
        titles.push_back(GetColumn(n).GetTitle());

    // this loop is however over positions and not indices
    unsigned pos;
    for ( pos = 0; pos < count; pos++ )
    {
        int& idx = order[pos];
        if ( GetColumn(idx).IsHidden() )
        {
            // indicate that this one is hidden
            idx = ~idx;
        }
    }

    // do show it
    wxHeaderColumnsRearrangeDialog dlg(this, order, titles);
    if ( dlg.ShowModal() == wxID_OK )
    {
        // and apply the changes
        order = dlg.GetOrder();
        for ( pos = 0; pos < count; pos++ )
        {
            int& idx = order[pos];
            const bool show = idx >= 0;
            if ( !show )
            {
                // make all indices positive for passing them to SetColumnsOrder()
                idx = ~idx;
            }

            if ( show != GetColumn(idx).IsShown() )
                UpdateColumnVisibility(idx, show);
        }

        UpdateColumnsOrder(order);
        SetColumnsOrder(order);

        return true;
    }
#endif // wxUSE_REARRANGECTRL

    return false;
}
Exemple #2
0
bool CBOINCListCtrl::IsColumnOrderStandard() {
#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
    int i;
    wxArrayInt aOrder = GetColumnsOrder();
    int orderCount = aOrder.GetCount();
    for (i=1; i<orderCount; ++i) {
        if(aOrder[i] < aOrder[i-1]) return false;
    }
#endif
    return true;
}
Exemple #3
0
unsigned int wxHeaderCtrlBase::GetColumnPos(unsigned int idx) const
{
    const unsigned count = GetColumnCount();

    wxCHECK_MSG( idx < count, wxNO_COLUMN, "invalid index" );

    const wxArrayInt order = GetColumnsOrder();
    int pos = order.Index(idx);
    wxCHECK_MSG( pos != wxNOT_FOUND, wxNO_COLUMN, "column unexpectedly not displayed at all" );

    return (unsigned int)pos;
}
void wxGxContentView::SetStyle(wxGISEnumContentsViewStyle style)
{
    if(m_current_style == style)
        return;


    if(m_current_style == enumGISCVReport)
    {
        //store values
        m_anWidth.Clear();
        for (int i = 0; i < GetColumnCount(); ++i)
        {
            m_anWidth.Add( GetColumnWidth(i) );
        }
#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        m_anOrder = GetColumnsOrder();
#endif
    }
    m_current_style = style;

	switch(m_current_style)
	{
	case enumGISCVReport:
        SetSingleStyle(wxLC_REPORT);

        InitColumns();

        for(size_t i = 0; i < m_anWidth.GetCount(); ++i)
            SetColumnWidth(i, m_anWidth[i]);
#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        SetColumnsOrder(m_anOrder);
#endif

        SetColumnImage(m_currentSortCol, m_bSortAsc ? 0 : 1);

		break;
	case enumGISCVSmall:
        SetSingleStyle(wxLC_SMALL_ICON);
		break;
	case enumGISCVLarge:
        SetSingleStyle(wxLC_ICON);
		break;
	case enumGISCVList:
        SetSingleStyle(wxLC_LIST);
		break;
	}

    RefreshAll();
}
unsigned int wxHeaderCtrlBase::GetColumnPos(unsigned int idx) const
{
    const unsigned count = GetColumnCount();

    wxCHECK_MSG( idx < count, wxNO_COLUMN, "invalid index" );

    const wxArrayInt order = GetColumnsOrder();
    for ( unsigned n = 0; n < count; n++ )
    {
        if ( (unsigned)order[n] == idx )
            return n;
    }

    wxFAIL_MSG( "column unexpectedly not displayed at all" );

    return wxNO_COLUMN;
}
unsigned int wxHeaderCtrlBase::GetColumnAt(unsigned int pos) const
{
    wxCHECK_MSG( pos < GetColumnCount(), wxNO_COLUMN, "invalid position" );

    return GetColumnsOrder()[pos];
}
void wxGxContentView::Serialize(wxXmlNode* pRootNode, bool bStore)
{
	if(pRootNode == NULL)
		return;

	if(bStore)
	{
        if(pRootNode->HasAttribute(wxT("style")))
            pRootNode->DeleteAttribute(wxT("style"));
        SetDecimalValue(pRootNode, wxT("style"), m_current_style);
        if(pRootNode->HasAttribute(wxT("sort")))
            pRootNode->DeleteAttribute(wxT("sort"));
        SetBoolValue(pRootNode, wxT("sort"), m_bSortAsc);
        if(pRootNode->HasAttribute(wxT("sort_col")))
            pRootNode->DeleteAttribute(wxT("sort_col"));
        SetDecimalValue(pRootNode, wxT("sort_col"), m_currentSortCol);

        if(m_current_style == enumGISCVReport)
        {
            //store values
            m_anWidth.Clear();
            for (int i = 0; i < GetColumnCount(); ++i)
            {
                m_anWidth.Add( GetColumnWidth(i) );
            }
    #ifdef wxHAS_LISTCTRL_COLUMN_ORDER
            m_anOrder = GetColumnsOrder();
    #endif
        }

        wxString sCols;
        for(size_t i = 0; i < m_anWidth.GetCount(); ++i)
        {
            sCols += wxString::Format(wxT("%d"), m_anWidth[i]);
            sCols += wxT("|");
        }
        if(pRootNode->HasAttribute(wxT("cols_width")))
            pRootNode->DeleteAttribute(wxT("cols_width"));
        pRootNode->AddAttribute(wxT("cols_width"), sCols);

#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        wxString sOrd;
        for(size_t i = 0; i < m_anOrder.GetCount(); ++i)
        {
            sOrd += wxString::Format(wxT("%d"), m_anOrder[i]);
            sOrd += wxT("|");
        }

        if(pRootNode->HasAttribute(wxT("cols_order")))
            pRootNode->DeleteAttribute(wxT("cols_order"));
        pRootNode->AddAttribute(wxT("cols_order"), sOrd);
#endif

	}
	else
	{
		m_bSortAsc = GetBoolValue(pRootNode, wxT("sort"), true);
		m_currentSortCol = GetDecimalValue(pRootNode, wxT("sort_col"), 0);
		wxGISEnumContentsViewStyle style = (wxGISEnumContentsViewStyle)GetDecimalValue(pRootNode, wxT("style"), 0);
        //load col width
        wxString sCol = pRootNode->GetAttribute(wxT("cols_width"));
	    wxStringTokenizer tkz(sCol, wxString(wxT("|")), wxTOKEN_RET_EMPTY );
	    while ( tkz.HasMoreTokens() )
	    {
		    wxString token = tkz.GetNextToken();
		    //token.Replace(wxT("|"), wxT(""));
		    int nWidth = wxAtoi(token); //wxLIST_AUTOSIZE
            m_anWidth.Add(nWidth);
	    }

#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
        //load col order
        wxString sOrd = pRootNode->GetAttribute(wxT("cols_order"));
	    wxStringTokenizer tkz_ord(sOrd, wxString(wxT("|")), wxTOKEN_RET_EMPTY );
	    while ( tkz_ord.HasMoreTokens() )
	    {
		    wxString token = tkz_ord.GetNextToken();
		    //token.Replace(wxT("|"), wxT(""));
		    m_anOrder.Add( wxAtoi(token) );
	    }
#endif

        SetStyle(style);

        SORTDATA sortdata = {m_bSortAsc, m_currentSortCol};
		SortItems(GxObjectCVCompareFunction, (long)&sortdata);
	}
}
Exemple #8
0
bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) {
    wxString    strBaseConfigLocation = wxEmptyString;
    wxInt32     iIndex = 0;
    wxInt32     iStdColumnCount = 0;
    wxInt32     iActualColumnCount = GetColumnCount();
    int         i, j;

    wxASSERT(pConfig);

    // Retrieve the base location to store configuration information
    // Should be in the following form: "/Projects/"
    strBaseConfigLocation = pConfig->GetPath() + wxT("/");

    iStdColumnCount = m_pParentView->m_iStdColWidthOrder.size();

    // Cycle through the columns recording their widths
    for (iIndex = 0; iIndex < iActualColumnCount; iIndex++) {
        m_pParentView->m_iStdColWidthOrder[m_pParentView->m_iColumnIndexToColumnID[iIndex]] = GetColumnWidth(iIndex);
    }
    
    for (iIndex = 0; iIndex < iStdColumnCount; iIndex++) {
        pConfig->SetPath(strBaseConfigLocation + m_pParentView->m_aStdColNameOrder->Item(iIndex));
        pConfig->Write(wxT("Width"), m_pParentView->m_iStdColWidthOrder[iIndex]);
    }

    // Save sorting column and direction
    pConfig->SetPath(strBaseConfigLocation);
    pConfig->Write(wxT("SortColumn"), m_pParentView->m_iSortColumnID);
    pConfig->Write(wxT("ReverseSortOrder"), m_pParentView->m_bReverseSort);

    // Save Column Order
    wxString strColumnOrder;
    wxString strBuffer;
    wxString strHiddenColumns;
    wxArrayInt aOrder(iActualColumnCount);
    CBOINCBaseView* pView = (CBOINCBaseView*)GetParent();
    wxASSERT(wxDynamicCast(pView, CBOINCBaseView));

#ifdef wxHAS_LISTCTRL_COLUMN_ORDER
    aOrder = GetColumnsOrder();
#else
    for (i = 0; i < iActualColumnCount; ++i) {
        aOrder[i] = i;
    }
#endif
    
    strColumnOrder.Printf(wxT("%s"), pView->m_aStdColNameOrder->Item(pView->m_iColumnIndexToColumnID[aOrder[0]]));
    
    for (i = 1; i < iActualColumnCount; ++i)
    {
        strBuffer.Printf(wxT(";%s"), pView->m_aStdColNameOrder->Item(pView->m_iColumnIndexToColumnID[aOrder[i]]));
        strColumnOrder += strBuffer;
    }

    pConfig->Write(wxT("ColumnOrder"), strColumnOrder);

    strHiddenColumns = wxEmptyString;
    for (i = 0; i < iStdColumnCount; ++i) {
        bool found = false;
        for (j = 0; j < iActualColumnCount; ++j) {
            if (pView->m_iColumnIndexToColumnID[aOrder[j]] == i) {
                found = true;
                break;
            }
        }
        if (found) continue;
        if (!strHiddenColumns.IsEmpty()) {
            strHiddenColumns += wxT(";");
        }
        strHiddenColumns += pView->m_aStdColNameOrder->Item(i);
    }
    pConfig->Write(wxT("HiddenColumns"), strHiddenColumns);
    
    return true;
}