/// Finds the next item in the tree
ctConfigItem* ctConfigToolDoc::FindNextItem(ctConfigItem* item, bool wrap)
{
    if (!item)
        return GetTopItem();

    // First, try to find the first child
    if (item->GetChildCount() > 0)
    {
        return item->GetChild(0);
    }
    else
    {
        ctConfigItem* p = item;
        while (p)
        {
            ctConfigItem* toFind = FindNextSibling(p);
            if (toFind)
                return toFind;
            p = p->GetParent();
        }
    }

    // Finally, wrap around to the root.
    if (wrap)
        return GetTopItem();
    else
        return NULL;
}
Esempio n. 2
0
void DocumentListCtrl::SelectFirstItem ()
{
	// select first item
	if (_sortedIndices.size() != 0) 
	{
		SetItemState (GetTopItem (), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
		EnsureVisible (GetTopItem ());
	}
}
/// Refresh dependencies
void ctConfigToolDoc::RefreshDependencies(ctConfigItem* item)
{
    if (item==NULL)
        return;

    wxArrayString requiresArr;
    wxString requires = item->GetPropertyString(wxT("requires"));
    wxString precludes = item->GetPropertyString(wxT("precludes"));
    wxString enabledIf = item->GetPropertyString(wxT("enabled-if"));
    wxString enabledIfNot = item->GetPropertyString(wxT("enabled-if-not"));
    wxString indeterminateIf = item->GetPropertyString(wxT("indeterminate-if"));
    wxString context = item->GetPropertyString(wxT("context"));

    if (!requires.IsEmpty())
        item->StringToArray(requires, requiresArr);

    if (!precludes.IsEmpty())
        item->StringToArray(precludes, requiresArr);

    if (!enabledIfNot.IsEmpty())
        item->StringToArray(enabledIfNot, requiresArr);

    if (!enabledIf.IsEmpty())
        item->StringToArray(enabledIf, requiresArr);

    if (!indeterminateIf.IsEmpty())
        item->StringToArray(indeterminateIf, requiresArr);

    // Add the parent to the list of dependencies, if the
    // parent is a check or radio group.
    ctConfigItem* parent = item->GetParent();
    if (parent &&
        (parent->GetType() == ctTypeCheckGroup ||
        parent->GetType() == ctTypeRadioGroup))
        requiresArr.Add(parent->GetName());

    // Also look in 'context' since these items
    // are another kind of dependency (switching to
    // a different platform may cause the dependencies
    // to be evaluated differently).
    if (!context.IsEmpty())
        item->StringToArray(context, requiresArr);

    size_t i;
    for (i = 0; i < requiresArr.GetCount(); i++)
    {
        wxString itemName(requiresArr[i]);
        ctConfigItem* otherItem = GetTopItem()->FindItem(itemName);
        if (otherItem && !otherItem->GetDependents().Member(item))
        {
            otherItem->GetDependents().Append(item);
        }
    }
    for ( wxObjectList::compatibility_iterator node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
    {
        ctConfigItem* child = (ctConfigItem*) node->GetData();
        RefreshDependencies(child);
    }
}
void CustomVirtListCtrl<T,L>::RefreshVisibleItems()
{
	if ( m_data.empty() )
		return;
	const long topItemIndex = GetTopItem();
	const long range = topItemIndex + GetCountPerPage();
	RefreshItems( topItemIndex,  LSL::Util::Clamp( range, topItemIndex, (long) m_data.size() -1 ) );
}
/// Generate the text of a setup.h
wxString ctConfigToolDoc::GenerateSetup()
{
    wxString str;
    str << wxT("/*\n * setup.h\n * Generated by wxConfigTool\n *\n */\n\n");

    GenerateSetup(GetTopItem(), str);

    return str;
}
Esempio n. 6
0
HRESULT CGamesList::OnSetCurSel(XUIMessageSetCurSel *pSetCurSelData, BOOL &bHandled )
{

	int nFocalPoint = 4;

	if(SETTINGS::getInstance().getGameListVisual() == 0)
		return S_OK;

	if(SETTINGS::getInstance().getGameListVisual() == 1)
		nFocalPoint = 4;
	else if(SETTINGS::getInstance().getGameListVisual() == 2)
		nFocalPoint = 3;
	else
		nFocalPoint = 4;

	if(flag == false)
	{
	
		int nFocalInverse = GetVisibleItemCount() - nFocalPoint - 1;
		
		int previousItem = GetCurSel();
		int currentTopItem = GetTopItem();
		int currentItem = pSetCurSelData->iItem;
		int direction = currentItem - previousItem;
		int listCount = GetItemCount();

		if(direction > 0) 
		{
			currentTopItem++;
			if(currentItem > nFocalPoint && currentItem <= listCount - nFocalInverse - 1)
			{
				SetTopItem(currentTopItem);
				pSetCurSelData->iItem = currentTopItem + nFocalPoint;
				flag = true;
			}
		}
		else
		{
			currentTopItem--;
			if(currentItem >= nFocalPoint && currentItem < listCount - nFocalInverse - 1)
			{
				SetTopItem(currentTopItem);
				pSetCurSelData->iItem = currentTopItem + nFocalPoint;
				flag = true;
			}
		}
	}
	else
	{
		flag = false;
		bHandled = true;
	}

	return S_OK;
}
Esempio n. 7
0
void CLocalListView::FinishComparison()
{
	SetItemCount(m_indexMapping.size());

	ComparisonRestoreSelections();

	RefreshListOnly();

	CComparableListing* pOther = GetOther();
	if (!pOther)
		return;

	pOther->ScrollTopItem(GetTopItem());
}
Esempio n. 8
0
void wxListCtrlEx::ScrollTopItem(int item)
{
	const int current = GetTopItem();

	int delta = item - current;
	if (!delta)
		return;

	wxRect rect;
	GetItemRect(current, rect, wxLIST_RECT_BOUNDS);

	delta *= rect.GetHeight();
	ScrollList(0, delta);
}
/// Clear dependencies
void ctConfigToolDoc::ClearDependencies(ctConfigItem* item)
{
    if (!item) {
        item = GetTopItem();
        if (!item)
            return;
    }

    item->GetDependents().Clear();
    for ( wxObjectList::compatibility_iterator node = item->GetChildren().GetFirst(); node; node = node->GetNext() )
    {
        ctConfigItem* child = (ctConfigItem*) node->GetData();
        ClearDependencies(child);
    }
}
/// Generate a configure command
wxString ctConfigToolDoc::GenerateConfigureCommand()
{
    wxString str;
    str << wxT("# configurewx\n# Generated by wxConfigTool\n\n");

    wxString path = GetFrameworkDir(true);
    bool makeUnix = true;
    if (!path.IsEmpty())
    {
        if (makeUnix)
            path += wxT("/");
        else
            path += wxFILE_SEP_PATH ;
    }

    str << path << wxT("configure");

    // Find the target to use
    ctConfigItem* platformsFolder = GetTopItem()->FindItem(wxT("Target"));
    if (platformsFolder)
    {
        for ( wxObjectList::compatibility_iterator node = platformsFolder->GetChildren().GetFirst(); node; node = node->GetNext() )
        {
            ctConfigItem* child = (ctConfigItem*) node->GetData();
            if (child->GetType() == ctTypeBoolRadio && child->IsEnabled())
            {
                wxString configureCommand = child->GetPropertyString(wxT("configure-command"));
                if (!configureCommand.IsEmpty())
                    str << wxT(" ") << configureCommand;
            }
        }
    }

    GenerateConfigureCommand(GetTopItem(), str);
    return str;
}
HRESULT CXlinkBuddyList::LoadBuddyList(void)
{
	// Our list is swapping, let's block out changes
	bIsLoaded = false;
	
	// Refresh our copy of the arena item
	CKaiBuddyManager::getInstance().getBuddyInfo(&m_pBuddyList);
	CKaiBuddyManager::getInstance().getBuddyLookupInfo(&m_BuddyNames);

	int nSize = m_nCurrentListSize = (int)m_pBuddyList.size();

	// Local Variables
	unsigned int nCurrentSel = 0;
	unsigned int nCurrentTop = 0;

	// Set our current selection 
	if( nSize > 0 && GetCurSel() == -1 )
		nCurrentSel = 0;
	else
		nCurrentSel = GetCurSel();

	// Set our top most item
	nCurrentTop = GetTopItem();

	// Now let's clear our entire list, so we can update it
	DeleteItems(0, GetItemCount());

	// Now let's add in our new list items
	if( nSize > 0 ) {
		InsertItems( 0, nSize );
		if( bInitializeList == true ) {
			nCurrentTop = 0;
			bInitializeList = false;
		} else if( (int)nCurrentTop > nSize ) {
			nCurrentTop = nSize;
		}
	}

	// Restore list position
	SetTopItem(nCurrentTop);
	SetCurSel(nCurrentSel);

	// Notify that the list has been loaded
	if(nSize > 0 ) bIsLoaded = true;

	// Return Successfully
	return S_OK;
}
Esempio n. 12
0
void wxListCtrlEx::ScrollTopItem(int item)
{
#ifdef __WXMSW__
	const int current = GetTopItem();

	int delta = item - current;
	if (!delta)
		return;

	wxRect rect;
	GetItemRect(current, rect, wxLIST_RECT_BOUNDS);

	delta *= rect.GetHeight();
	ScrollList(0, delta);
#else
	GetMainWindow()->Scroll(0, item);
	EnsureVisible(item);
#endif
}
Esempio n. 13
0
HRESULT CGamesList::OnSetListContent(FSDMessageSetListContent * pSetListContent, BOOL &bHandled )
{
	// Unpack the message and store into local vector
	m_vListContent = pSetListContent->pVec;
	
	if(m_vListContent != NULL)
		SetListSize((int)m_vListContent->size());

	// Local variables used 
	unsigned int nCurrentSel = 0;
	int nCurrentTop = 0;

	// If interested, save current list position for later use
	if(pSetListContent->bRetainSelection){
		
		if(GetListSize() > 0 && GetCurSel() == -1)
			nCurrentSel = 0;
		else
			nCurrentSel = GetCurSel();
		nCurrentTop = GetTopItem();
		if (nCurrentTop == -1)
			nCurrentTop = 0;
	}

	// Clear the current list and prepare the list to use a new data vector
	DeleteItems(0, GetItemCount());
	if(pSetListContent->pVec != NULL){
		InsertItems(0, pSetListContent->pVec->size());
		if( nCurrentTop > pSetListContent->pVec->size() )
			nCurrentTop = pSetListContent->pVec->size();
	}

	// Restore list position
	SetTopItem(nCurrentTop);
	SetCurSel(nCurrentSel);

	if(pSetListContent->pVec != NULL)
		GameContentManager::getInstance().RefreshCurrentContent(m_CurrentGame, nCurrentSel, pSetListContent->pVec->size());

	// Return Successfully
	bHandled = TRUE;
	return S_OK;
}
void CBOINCListCtrl::DrawProgressBars()
{
    long topItem, numItems, numVisibleItems, i, row;
    wxRect r, rr;
    int w = 0, x = 0, xx, yy, ww;
    int progressColumn = m_pParentView->GetProgressColumn();
    
#if USE_NATIVE_LISTCONTROL
    wxClientDC dc(this);
    m_bProgressBarEventPending = false;
#else
    wxClientDC dc(GetMainWin());   // Available only in wxGenericListCtrl
#endif

    if (progressColumn < 0) {
        m_iRowsNeedingProgressBars.Clear();
        return;
    }

    int n = (int)m_iRowsNeedingProgressBars.GetCount();
    if (n <= 0) return;
    
    wxColour progressColor = wxTheColourDatabase->Find(wxT("LIGHT BLUE"));
    wxBrush progressBrush(progressColor);
    
    numItems = GetItemCount();
    if (numItems) {
        topItem = GetTopItem();     // Doesn't work properly for Mac Native control in wxMac-2.8.7

        numVisibleItems = GetCountPerPage();
        ++numVisibleItems;

        if (numItems <= (topItem + numVisibleItems)) numVisibleItems = numItems - topItem;

        x = 0;
        for (i=0; i< progressColumn; i++) {
            x += GetColumnWidth(i);
        }
        w = GetColumnWidth(progressColumn);
        
#if USE_NATIVE_LISTCONTROL
        x -= GetScrollPos(wxHORIZONTAL);
#else
        GetMainWin()->CalcScrolledPosition(x, 0, &x, &yy);
#endif
        wxFont theFont = GetFont();
        dc.SetFont(theFont);
        
        for (int i=0; i<n; ++i) {
            row = m_iRowsNeedingProgressBars[i];
            if (row < topItem) continue;
            if (row > (topItem + numVisibleItems -1)) continue;
        

            GetItemRect(row, r);
#if ! USE_NATIVE_LISTCONTROL
            r.y = r.y - GetHeaderHeight() - 1;
#endif
            r.x = x;
            r.width = w;
            r.Inflate(-1, -2);
            rr = r;

            wxString progressString = m_pParentView->GetProgressText(row);
            dc.GetTextExtent(progressString, &xx, &yy);
            
            r.y += (r.height - yy - 1) / 2;
            
            // Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents()
            if (xx > r.width) {
                int ellipsisWidth;
                dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL);
                if (ellipsisWidth > r.width) {
                    progressString.Clear();
                    xx = 0;
                } else {
                    do {
                        progressString.Truncate( progressString.length() - 1 );
                        dc.GetTextExtent( progressString, &xx, &yy);
                    } while (xx + ellipsisWidth > r.width && progressString.length() );
                    progressString.append( wxT("...") );
                    xx += ellipsisWidth;
                }
            }
            
            dc.SetLogicalFunction(wxCOPY);
            dc.SetBackgroundMode(wxSOLID);
            dc.SetPen(progressColor);
            dc.SetBrush(progressBrush);
            dc.DrawRectangle( rr );

            rr.Inflate(-2, -1);
            ww = rr.width * m_pParentView->GetProgressValue(row);
            rr.x += ww;
            rr.width -= ww;

#if 0
            // Show background stripes behind progress bars
            wxListItemAttr* attr = m_pParentView->FireOnListGetItemAttr(row);
            wxColour bkgd = attr->GetBackgroundColour();
            dc.SetPen(bkgd);
            dc.SetBrush(bkgd);
#else
            dc.SetPen(*wxWHITE_PEN);
            dc.SetBrush(*wxWHITE_BRUSH);
#endif
            dc.DrawRectangle( rr );

            dc.SetPen(*wxBLACK_PEN);
            dc.SetBackgroundMode(wxTRANSPARENT);
            if (xx > (r.width - 7)) {
                dc.DrawText(progressString, r.x, r.y);
            } else {
                dc.DrawText(progressString, r.x + (w - 8 - xx), r.y);
            }
        }
    }
    m_iRowsNeedingProgressBars.Clear();
}
Esempio n. 15
0
// This shows a little tooltip with the current Game's emulation state
void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
{
	int flags;
	long subitem = 0;
	const long item = HitTest(event.GetPosition(), flags, &subitem);
	static int lastItem = -1;

	if (GetColumnCount() <= 1)
		return;

	if (item != wxNOT_FOUND)
	{
		wxRect Rect;
#ifdef __WXMSW__
		if (subitem == COLUMN_EMULATION_STATE)
#else
		// The subitem parameter of HitTest is only implemented for wxMSW.  On
		// all other platforms it will always be -1.  Check the x position
		// instead.
		GetItemRect(item, Rect);
		if (Rect.GetX() + Rect.GetWidth() - GetColumnWidth(COLUMN_EMULATION_STATE) < event.GetX())
#endif
		{
			if (toolTip || lastItem == item || this != FindFocus())
			{
				if (lastItem != item) lastItem = -1;
				event.Skip();
				return;
			}

			// Emulation status
			static const char* const emuState[] = { "Broken", "Intro", "In-Game", "Playable", "Perfect" };

			const GameListItem& rISO = *m_ISOFiles[GetItemData(item)];

			const int emu_state = rISO.GetEmuState();
			const std::string& issues = rISO.GetIssues();

			// Show a tooltip containing the EmuState and the state description
			if (emu_state > 0 && emu_state < 6)
			{
				char temp[2048];
				sprintf(temp, "^ %s%s%s", emuState[emu_state - 1],
						issues.size() > 0 ? " :\n" : "", issues.c_str());
				toolTip = new wxEmuStateTip(this, wxString(temp, *wxConvCurrent), &toolTip);
			}
			else
				toolTip = new wxEmuStateTip(this, _("Not Set"), &toolTip);

			// Get item Coords
			GetItemRect(item, Rect);
			int mx = Rect.GetWidth();
			int my = Rect.GetY();
#ifndef __WXMSW__
			// For some reason the y position does not account for the header
			// row, so subtract the y position of the first visible item.
			GetItemRect(GetTopItem(), Rect);
			my -= Rect.GetY();
#endif
			// Convert to screen coordinates
			ClientToScreen(&mx, &my);
			toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(COLUMN_EMULATION_STATE),
						my, GetColumnWidth(COLUMN_EMULATION_STATE), Rect.GetHeight()));
			toolTip->SetPosition(wxPoint(mx - GetColumnWidth(COLUMN_EMULATION_STATE),
						my - 5 + Rect.GetHeight()));
			lastItem = item;
		}
	}
	if (!toolTip)
		lastItem = -1;

	event.Skip();
}
Esempio n. 16
0
bool CQueueViewBase::RemoveItem(CQueueItem* pItem, bool destroy, bool updateItemCount /*=true*/, bool updateSelections /*=true*/)
{
	if (pItem->GetType() == QueueItemType_File || pItem->GetType() == QueueItemType_Folder)
	{
		wxASSERT(m_fileCount > 0);
		m_fileCount--;
		m_fileCountChanged = true;
	}
	else if (pItem->GetType() == QueueItemType_FolderScan)
	{
		wxASSERT(m_folderScanCount > 0);
		m_folderScanCount--;
		m_folderScanCountChanged = true;

	}

	int index = 0;
	if (updateSelections)
		index = GetItemIndex(pItem);

	CQueueItem* topLevelItem = pItem->GetTopLevelItem();

	int count = topLevelItem->GetChildrenCount(true);
	topLevelItem->RemoveChild(pItem, destroy);

	bool didRemoveParent;

	int oldCount = m_itemCount;
	if (!topLevelItem->GetChild(0))
	{
		std::vector<CServerItem*>::iterator iter;
		for (iter = m_serverList.begin(); iter != m_serverList.end(); iter++)
		{
			if (*iter == topLevelItem)
				break;
		}
		if (iter != m_serverList.end())
			m_serverList.erase(iter);

		UpdateSelections_ItemRangeRemoved(GetItemIndex(topLevelItem), count + 1);

		delete topLevelItem;

		m_itemCount -= count + 1;
		if (updateItemCount)
			SaveSetItemCount(m_itemCount);

		didRemoveParent = true;
	}
	else
	{
		count -= topLevelItem->GetChildrenCount(true);

		if (updateSelections)
			UpdateSelections_ItemRangeRemoved(index, count);

		m_itemCount -= count;
		if (updateItemCount)
			SaveSetItemCount(m_itemCount);

		didRemoveParent = false;
	}

	if (updateItemCount)
	{
		if (m_fileCountChanged || m_folderScanCountChanged)
			DisplayNumberQueuedFiles();
		if (oldCount > m_itemCount)
		{
			bool eraseBackground = GetTopItem() + GetCountPerPage() + 1 >= m_itemCount;
			RefreshListOnly(eraseBackground);
			if (eraseBackground)
				Update();
		}
	}

	return didRemoveParent;
}
Esempio n. 17
0
void CMusikListCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
{
	wxBufferedPaintDC dc(this);

	MSWDefWindowProc(WM_ERASEBKGND, (WPARAM) (HDC) dc.GetHDC(), 0);
	MSWDefWindowProc(WM_PAINT, (WPARAM) (HDC) dc.GetHDC(), 0);

	/* copied from original wxwindows code */
    // Reset the device origin since it may have been set
	dc.SetDeviceOrigin(0, 0);
    bool drawHRules = ((GetWindowStyle() & wxLC_HRULES) != 0);
    bool drawVRules = ((GetWindowStyle() & wxLC_VRULES) != 0);

    if (!drawHRules && !drawVRules)
        return;
    if ((GetWindowStyle() & wxLC_REPORT) == 0)
        return;
    

    wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);
    dc.SetPen(pen);
    dc.SetBrush(* wxTRANSPARENT_BRUSH);

    wxSize clientSize = GetClientSize();
    wxRect itemRect;
    int cy=0;

    int itemCount = GetItemCount();
    int i;
    if (drawHRules)
    {
        long top = GetTopItem();
        for (i = top; i < top + GetCountPerPage() + 1; i++)
        {
            if (GetItemRect(i, itemRect))
            {
                cy = itemRect.GetTop();
                if (i != 0) // Don't draw the first one
                {
                    dc.DrawLine(0, cy, clientSize.x, cy);
                }
                // Draw last line
                if (i == itemCount - 1)
                {
                    cy = itemRect.GetBottom();
                    dc.DrawLine(0, cy, clientSize.x, cy);
                }
            }
        }
    }
    i = itemCount - 1;
    if (drawVRules && (i > -1))
    {
        wxRect firstItemRect;
        GetItemRect(0, firstItemRect);

        if (GetItemRect(i, itemRect))
        {
            int col;
            int x = itemRect.GetX();
            for (col = 0; col < GetColumnCount(); col++)
            {
                int colWidth = GetColumnWidth(col);
                x += colWidth ;
                dc.DrawLine(x-1, firstItemRect.GetY() - 2, x-1, itemRect.GetBottom());
            }
        }
    }
}
/// Refresh dependencies
void ctConfigToolDoc::RefreshDependencies()
{
    ClearDependencies(GetTopItem());
    RefreshDependencies(GetTopItem());
}