void  CMusikPlayer::MovePlaylistEntrys(size_t nMoveTo ,const wxArrayInt &arrToMove)
{
	//wxCriticalSectionLocker locker( m_critInternalData);
	wxASSERT(nMoveTo >= 0 && nMoveTo <= m_Playlist.GetCount()); 
	int i = arrToMove.GetCount() - 1;
	// first move all entrys which are behind nMoveTo;
	for(;i >= 0 ; i--)
	{

		if(nMoveTo > (size_t)arrToMove[i])
			break;
		size_t ToMoveIdx = arrToMove[i] + ( arrToMove.GetCount() - 1 - i);
		m_Playlist.Insert(m_Playlist.Detach(ToMoveIdx),nMoveTo);

		if(ToMoveIdx > m_SongIndex && nMoveTo <= m_SongIndex)
			m_SongIndex++;
		else if(ToMoveIdx == m_SongIndex)
			m_SongIndex = nMoveTo;
	}
	// now move all entry which are before
	for(int j = i; j >= 0; j--)
	{
		size_t MoveToIdx = nMoveTo - (i - j) - 1;
		m_Playlist.Insert(m_Playlist.Detach(arrToMove[j]),MoveToIdx);
		if((size_t)arrToMove[j] < m_SongIndex && MoveToIdx  > m_SongIndex)
			m_SongIndex--;
		else if( m_SongIndex  == MoveToIdx)
			m_SongIndex++;
		else if((size_t)arrToMove[j] == m_SongIndex)
			m_SongIndex = MoveToIdx;

	}
}
Example #2
0
bool DotWriter::IsInArray(int index, const wxArrayInt& arr)
{
    for(unsigned int i = 0; i < arr.GetCount(); i++) {
        if(arr.Item(i) == index) return true;
    }
    return false;
}
Example #3
0
void MainBook::SaveSession(SessionEntry &session, wxArrayInt& intArr)
{
    std::vector<LEditor*> editors;
    bool retain_order(true);
    GetAllEditors(editors, retain_order);

    session.SetSelectedTab(0);
    std::vector<TabInfo> vTabInfoArr;
    for (size_t i = 0; i < editors.size(); i++) {
        if ( (intArr.GetCount() > i) && (!intArr.Item(i)) ) {
            // If we're saving only selected editors, and this isn't one of them...
            continue;
        }
        if (editors[i] == GetActiveEditor()) {
            session.SetSelectedTab(vTabInfoArr.size());
        }
        TabInfo oTabInfo;
        oTabInfo.SetFileName(editors[i]->GetFileName().GetFullPath());
        oTabInfo.SetFirstVisibleLine(editors[i]->GetFirstVisibleLine());
        oTabInfo.SetCurrentLine(editors[i]->GetCurrentLine());

        wxArrayString astrBookmarks;
        editors[i]->StoreMarkersToArray(astrBookmarks);
        oTabInfo.SetBookmarks(astrBookmarks);

        std::vector<int> folds;
        editors[i]->StoreCollapsedFoldsToArray(folds);
        oTabInfo.SetCollapsedFolds(folds);

        vTabInfoArr.push_back(oTabInfo);
    }
    session.SetTabInfoArr(vTabInfoArr);
}
Example #4
0
int wxListBox::GetSelections( wxArrayInt& aSelections ) const
{
    wxCHECK_MSG( m_list != NULL, wxNOT_FOUND, wxT("invalid listbox") );

    // get the number of selected items first
    GList *child = m_list->children;
    int count = 0;
    for (child = m_list->children; child != NULL; child = child->next)
    {
        if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED)
            count++;
    }

    aSelections.Empty();

    if (count > 0)
    {
        // now fill the list
        aSelections.Alloc(count); // optimization attempt
        int i = 0;
        for (child = m_list->children; child != NULL; child = child->next, i++)
        {
            if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED)
                 aSelections.Add(i);
        }
    }

    return count;
}
Example #5
0
// Return number of selections and an array of selected integers
int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
    aSelections.Empty();

    Widget listBox = (Widget) m_mainWidget;
    int *posList = NULL;
    int posCnt = 0;
    bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
    if (flag)
    {
        if (posCnt > 0)
        {
            aSelections.Alloc(posCnt);

            int i;
            for (i = 0; i < posCnt; i++)
                aSelections.Add(posList[i] - 1);

            XtFree ((char *) posList);
            return posCnt;
        }
        else
            return 0;
    }
    else
        return 0;
}
/* static */
void wxHeaderCtrlBase::MoveColumnInOrderArray(wxArrayInt& order,
        unsigned int idx,
        unsigned int pos)
{
    const unsigned count = order.size();

    wxArrayInt orderNew;
    orderNew.reserve(count);
    for ( unsigned n = 0; ; n++ )
    {
        // NB: order of checks is important for this to work when the new
        //     column position is the same as the old one

        // insert the column at its new position
        if ( orderNew.size() == pos )
            orderNew.push_back(idx);

        if ( n == count )
            break;

        // delete the column from its old position
        const unsigned idxOld = order[n];
        if ( idxOld == idx )
            continue;

        orderNew.push_back(idxOld);
    }

    order.swap(orderNew);
}
Example #7
0
//Setting values
void wxFixWidthImportCtrl::SetValues(const wxArrayInt& values)
{
    size_t nval = values.GetCount();
    size_t i, j, tot;
    int val;

    m_values.Clear();

    if ( nval < 1 )
    {   Refresh();
        FireEvent();
        return;
    }

    //Add the first value
    m_values.Add( values.Item(0) );

    //Add/insert the rest, avoiding duplicates
    for ( i=1; i<nval; i++)
    {   j=0;
        val = values.Item(i);
        tot = m_values.GetCount();
        while ( j < tot && val > m_values.Item(j) )
            j++;
        if ( j >= tot && val > m_values.Item(tot-1) )
            m_values.Add(val);
        if ( j < tot && val < m_values.Item(j) )
            m_values.Insert(val, j);
    }

    Refresh();
    FireEvent();
}
Example #8
0
bool wxGCDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
{

    bool isMeasuringContext = false;
    wxGraphicsContext* context = m_graphicContext;
    if (!context)
    {
        context = wxGraphicsRenderer::GetDefaultRenderer()->CreateMeasuringContext();
        isMeasuringContext = true;
    }

    widths.Clear();
    widths.Add(0,text.Length());
    if ( text.IsEmpty() )
        return true;

    wxArrayDouble widthsD;

    context->GetPartialTextExtents( text, widthsD );
    for ( size_t i = 0; i < widths.GetCount(); ++i )
        widths[i] = (wxCoord)(widthsD[i] + 0.5);

    if (isMeasuringContext)
        delete context;

    return true;
}
void
wxHeaderCtrlBase::DoResizeColumnIndices(wxArrayInt& colIndices, unsigned int count)
{
    // update the column indices array if necessary
    const unsigned countOld = colIndices.size();
    if ( count > countOld )
    {
        // all new columns have default positions equal to their indices
        for ( unsigned n = countOld; n < count; n++ )
            colIndices.push_back(n);
    }
    else if ( count < countOld )
    {
        // filter out all the positions which are invalid now while keeping the
        // order of the remaining ones
        wxArrayInt colIndicesNew;
        colIndicesNew.reserve(count);
        for ( unsigned n = 0; n < countOld; n++ )
        {
            const unsigned idx = colIndices[n];
            if ( idx < count )
                colIndicesNew.push_back(idx);
        }

        colIndices.swap(colIndicesNew);
    }
    //else: count didn't really change, nothing to do

    wxASSERT_MSG( colIndices.size() == count, "logic error" );
}
wxArrayInt wxHeaderCtrlBase::GetColumnsOrder() const
{
    const wxArrayInt order = DoGetColumnsOrder();

    wxASSERT_MSG( order.size() == GetColumnCount(), "invalid order array" );

    return order;
}
Example #11
0
FbAuthListModel::FbAuthListModel(const wxArrayInt &items, int code)
{
	m_position = items.Count() ? 1 : 0;
	Append(items);
	if (code) {
		int i = items.Index(code);
		if (i != wxNOT_FOUND) m_position = (size_t)i + 1;
	}
}
        void WadListBox::GetSelections(wxArrayInt& selection) const {
            selection.clear();

            unsigned long cookie;
            int index = GetFirstSelected(cookie);
            while (index != wxNOT_FOUND) {
                selection.push_back(index);
                index = GetNextSelected(cookie);
            }
        }
 void WadListBox::removeWads(const wxArrayInt& indices) {
     StringList newList;
     for (size_t i = 0; i < m_wadFiles.size(); i++) {
         if (std::find(indices.begin(), indices.end(), i) == indices.end())
             newList.push_back(m_wadFiles[i]);
     }
     m_wadFiles = newList;
     SetItemCount(m_wadFiles.size());
     Refresh();
 }
unsigned int PositionsPopup::GetCheckedItems(wxArrayInt &checkedItems) const
{
	unsigned int const itemsCount = GetCount();
	checkedItems.Empty();
	for( unsigned int i = 0; i < itemsCount; ++i )
	{
		if( IsChecked( i ) )
			checkedItems.Add( i );
	}
	return checkedItems.GetCount();
}
Example #15
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;
}
Example #16
0
void xLightsFrame::GetCheckedItems(wxArrayInt& chArray)
{
    chArray.Clear();
    int maxch = CheckListBoxTestChannels->GetCount();
    for (int ch=0; ch < maxch; ch++)
    {
        if (CheckListBoxTestChannels->IsChecked(ch))
        {
            chArray.Add(ch);
        }
    }
}
void CMusikLibrary::Query( const wxString & query, wxArrayInt & aReturn ,bool bClearArray )
{
	if(bClearArray)
	{

		aReturn.Clear();
		//--- run the query ---//
		aReturn.Alloc( GetSongCount() );
	}
    MusikDb::ResultCB cb(&aReturn, &db_callbackAddToIntArray);
 	m_pDB->Exec( ConvQueryToMB( query ), cb );
}
Example #18
0
int wxCheckListBox::GetSelections(wxArrayInt& aSelections) const
{
    int i;
    for (i = 0; (unsigned int)i < GetCount(); i++)
    {
        int selState = ListView_GetItemState(GetHwnd(), i, LVIS_SELECTED);
        if (selState == LVIS_SELECTED)
            aSelections.Add(i);
    }

    return aSelections.GetCount();
}
Example #19
0
/* static */
void wxHeaderCtrlBase::MoveColumnInOrderArray(wxArrayInt& order,
                                              unsigned int idx,
                                              unsigned int pos)
{
    int posOld = order.Index(idx);
    wxASSERT_MSG( posOld != wxNOT_FOUND, "invalid index" );

    if ( pos != (unsigned int)posOld )
    {
        order.RemoveAt(posOld);
        order.Insert(idx, pos);
    }
}
Example #20
0
/// Compare tabs
bool wxTextAttr::TabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2)
{
    if (tabs1.GetCount() != tabs2.GetCount())
        return false;

    size_t i;
    for (i = 0; i < tabs1.GetCount(); i++)
    {
        if (tabs1[i] != tabs2[i])
            return false;
    }
    return true;
}
Example #21
0
unsigned int wxCheckListBoxBase::GetCheckedItems(wxArrayInt& checkedItems) const
{
    unsigned int const numberOfItems = GetCount();

    checkedItems.clear();
    for ( unsigned int i = 0; i < numberOfItems; ++i )
    {
        if ( IsChecked(i) )
            checkedItems.push_back(i);
    }

    return checkedItems.size();
}
bool wxTextMeasureBase::GetPartialTextExtents(const wxString& text,
                                              wxArrayInt& widths,
                                              double scaleX)
{
    widths.Empty();
    if ( text.empty() )
        return true;

    MeasuringGuard guard(*this);

    widths.Add(0, text.length());

    return DoGetPartialTextExtents(text, widths, scaleX);
}
Example #23
0
int wxMacDataBrowserListControl::ListGetSelections( wxArrayInt& aSelections ) const
{
    aSelections.Empty();
    wxArrayMacDataItemPtr selectedItems;
    GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);

    int count = selectedItems.GetCount();

    for ( int i = 0; i < count; ++i)
    {
        aSelections.Add(GetLineFromItem(selectedItems[i]));
    }

    return count;
}
Example #24
0
int AutoCompData::FindString( const wxChar* word, const wxChar* words, const wxArrayInt& indicies )
{
   // Do a simple binary search using the index array
   // to find the strings in the word list.  It's all 
   // sorted, so it should be super quick.
   size_t i,
      lo = 0,
      hi = indicies.GetCount();
   int res;
   const wxChar* other;

   size_t wordLen = wxStrlen( word );

   while ( lo < hi ) {

      i = (lo + hi) / 2;

      other = words + indicies[i];
      res = wxStrnicmp(word, other, wordLen);
      if ( res < 0 )
         hi = i;
      else if ( res > 0 )
         lo = i + 1;
      else
         return i;
   }

   return -1;
}
int ProjectManager::AddMultipleFilesToProject(const wxArrayString& filelist, cbProject* project, wxArrayInt& targets)
{
    wxProgressDialog progress(_("Project Manager"), _("Please wait while adding files to project..."), filelist.GetCount(), Manager::Get()->GetAppFrame());

    if (!project)
        project = GetActiveProject();

    if (project)
    {
        project->BeginAddFiles();

        wxArrayString addedFiles; // to know which files were added successfully
        for (unsigned int i = 0; i < filelist.GetCount(); ++i)
        {
            if (DoAddFileToProject(filelist[i], project, targets) != 0)
                addedFiles.Add(filelist[i]);
            progress.Update(i);
        }

        if (addedFiles.GetCount() != 0)
        {
            for (unsigned int i = 0; i < addedFiles.GetCount(); ++i)
            {
                CodeBlocksEvent event(cbEVT_PROJECT_FILE_ADDED);
                event.SetProject(project);
                event.SetString(addedFiles[i]);
                Manager::Get()->GetPluginManager()->NotifyPlugins(event);
            }
        }

        project->EndAddFiles();
    }

    return targets.GetCount();
}
Example #26
0
int wxGetSelectedChoices(wxArrayInt& selections,
                         const wxString& message,
                         const wxString& caption,
                         const wxArrayString& choices,
                         wxWindow *parent,
                         int WXUNUSED(x), int WXUNUSED(y),
                         bool WXUNUSED(centre),
                         int WXUNUSED(width), int WXUNUSED(height))
{
    wxMultiChoiceDialog dialog(parent, message, caption, choices);

    // call this even if selections array is empty and this then (correctly)
    // deselects the first item which is selected by default
    dialog.SetSelections(selections);

    if ( dialog.ShowModal() != wxID_OK )
    {
        // NB: intentionally do not clear the selections array here, the caller
        //     might want to preserve its original contents if the dialog was
        //     cancelled
        return -1;
    }

    selections = dialog.GetSelections();
    return static_cast<int>(selections.GetCount());
}
Example #27
0
wxString ctlSQLGrid::GetExportLine(int row, wxArrayInt cols)
{
	wxString str;
	unsigned int col;

	if (GetNumberCols() == 0)
		return str;

	for (col = 0 ; col < cols.Count() ; col++)
	{
		if (col > 0)
			str.Append(settings->GetCopyColSeparator());

		wxString text = GetCellValue(row, cols[col]);

		bool needQuote  = false;
		if (settings->GetCopyQuoting() == 1)
		{
			needQuote = IsColText(cols[col]);
		}
		else if (settings->GetCopyQuoting() == 2)
			/* Quote everything */
			needQuote = true;

		if (needQuote)
			str.Append(settings->GetCopyQuoteChar());
		str.Append(text);
		if (needQuote)
			str.Append(settings->GetCopyQuoteChar());
	}
	return str;
}
Example #28
0
void RgbEffects::DrawCurtainVertical(bool topEdge, int ylimit, const wxArrayInt &SwagArray)
{
    int i,x,y;
    xlColour color;
    for (i=0; i<ylimit; i++)
    {
        GetMultiColorBlend(double(i) / double(BufferHt), true, color);
        y=topEdge ? BufferHt-i-1 : i;
        for (x=BufferWi-1; x>=0; x--)
        {
            SetPixel(x,y,color);
        }
    }

    // swag
    for (i=0; i<SwagArray.Count(); i++)
    {
        y=ylimit+i;
        GetMultiColorBlend(double(y) / double(BufferHt), true, color);
        if (topEdge) y=BufferHt-y-1;
        for (x=BufferWi-1; x>SwagArray[i];x--)
        {
            SetPixel(x,y,color);
        }
    }
}
Example #29
0
bool wxGCDCImpl::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
{
    wxCHECK_MSG( m_graphicContext, false, wxT("wxGCDC(cg)::DoGetPartialTextExtents - invalid DC") );
    widths.Clear();
    widths.Add(0,text.Length());
    if ( text.IsEmpty() )
        return true;

    wxArrayDouble widthsD;

    m_graphicContext->GetPartialTextExtents( text, widthsD );
    for ( size_t i = 0; i < widths.GetCount(); ++i )
        widths[i] = (wxCoord)(widthsD[i] + 0.5);

    return true;
}
Example #30
0
void RgbEffects::DrawCurtain(bool LeftEdge, int xlimit, const wxArrayInt &SwagArray)
{
    int i,x,y;
    xlColour color;
    for (i=0; i<xlimit; i++)
    {
        GetMultiColorBlend(double(i) / double(BufferWi), true, color);
        x=LeftEdge ? BufferWi-i-1 : i;
        for (y=BufferHt-1; y>=0; y--)
        {
            SetPixel(x,y,color);
        }
    }

    // swag
    for (i=0; i<SwagArray.Count(); i++)
    {
        x=xlimit+i;
        GetMultiColorBlend(double(x) / double(BufferWi), true, color);
        if (LeftEdge) x=BufferWi-x-1;
        for (y=BufferHt-1; y>SwagArray[i]; y--)
        {
            SetPixel(x,y,color);
        }
    }
}