示例#1
0
void MyTreeCtrl::RefreshTreeStatus(Builder *pBuilder)
{
	VTLOG("(Refreshing Tree Status)\n");

	wxTreeItemId root = GetRootItem();
	wxTreeItemId parent, item;

	wxTreeItemIdValue cookie;
	for (parent = GetFirstChild(root, cookie); parent; parent = GetNextChild(root, cookie))
	{
		wxTreeItemIdValue cookie2;
		for (item = GetFirstChild(parent, cookie2); item; item = GetNextChild(parent, cookie2))
		{
			MyTreeItemData *data = (MyTreeItemData *)GetItemData(item);
			if (data)
			{
				SetItemText(item, MakeItemName(data->m_pLayer));
				if (data->m_pLayer == pBuilder->GetActiveLayer())
					SelectItem(item);
				if (data->m_pLayer->GetVisible())
				{
					SetItemFont(item, *wxNORMAL_FONT);
					SetItemTextColour(item, wxColour(0,0,0));
				}
				else
				{
					SetItemFont(item, *wxITALIC_FONT);
					SetItemTextColour(item, wxColour(80,80,80));
				}
			}
		}
	}
}
示例#2
0
void browsers::TDTbrowser::OnTELLhighlightcell(wxString open_cell) {
   wxTreeItemId item;
   assert(findItem(open_cell, item, GetRootItem()));
   SetItemTextColour(active_structure,*wxBLACK);
//   SetItemFont(active_structure,_llfont_normal);
   active_structure = item;
   SetItemTextColour(active_structure,*wxBLUE);
//   SetItemFont(active_structure,_llfont_bold);
   EnsureVisible(active_structure);
}
示例#3
0
void ProcList::showList(int highlight)
{
	int c = 0;
	Freeze();
	DeleteAllItems();
	for (std::vector<Database::Item>::const_iterator i = list.items.begin(); i != list.items.end(); i++)
	{
		const Database::Symbol *sym = i->symbol;
		double inclusive = i->inclusive;
		double exclusive = i->exclusive;
		float inclusivepercent = i->inclusive * 100.0f / list.totalcount;
		float exclusivepercent = i->exclusive * 100.0f / list.totalcount;

		InsertItem(c, sym->procname.c_str(), -1);
		if(sym->isCollapseFunction || sym->isCollapseModule) {
			SetItemTextColour(c,wxColor(0,128,0));
		}
		setColumnValue(c, COL_EXCLUSIVE,	wxString::Format("%0.2fs",exclusive));
		setColumnValue(c, COL_INCLUSIVE,	wxString::Format("%0.2fs",inclusive));
		setColumnValue(c, COL_EXCLUSIVEPCT,	wxString::Format("%0.2f%%",exclusivepercent));
		setColumnValue(c, COL_INCLUSIVEPCT,	wxString::Format("%0.2f%%",inclusivepercent));
		setColumnValue(c, COL_SAMPLES,		wxString::Format("%0.2fs",exclusive));
		setColumnValue(c, COL_CALLSPCT,		wxString::Format("%0.2f%%",exclusivepercent));
		setColumnValue(c, COL_MODULE,		sym->module.c_str());
		setColumnValue(c, COL_SOURCEFILE,	sym->sourcefile.c_str());
		setColumnValue(c, COL_SOURCELINE,	::toString(sym->sourceline).c_str());

		c++;
	}

	this->SetItemState(highlight, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED|wxLIST_STATE_SELECTED);

	Thaw();
	EnsureVisible(highlight);
}
bool CocaSystemTree::moveDown( const coca::INode& node )
{
    wxTreeItemId id = findId( node );
    if ( !id.IsOk() ) { return false; }

    wxTreeItemId parentId = GetItemParent( id );
    if ( !parentId.IsOk() ) { return false; }

    wxTreeItemId nextId = GetNextSibling( id );
    if ( !nextId.IsOk() ) { return false; }

    // ready to move
    bool wasSelected = ( id == GetSelection() );

    Delete( id );
    id = InsertItem( parentId, nextId,
                         EditorTools::getName( node ), EditorTools::getImageIndex( node ),
                         -1, new ItemData( node ) );
    COCA_ASSERT( id.IsOk() );
    SetItemTextColour( id, EditorTools::getTextColour( node ) );

    addChildren( node, id );

    if ( wasSelected ) { SelectItem( id ); }

    return true;
}
示例#5
0
void browsers::TDTbrowser::OnTELLaddcell(wxString cellname, wxString parentname, int action) {
   wxTreeItemId item, newparent;
   switch (action) {
      case 0: {//new cell
         wxTreeItemId item = AppendItem(GetRootItem(), cellname);
         SetItemTextColour(item,GetItemTextColour(GetRootItem()));
         break;
      }   
      case 1: {//first reference of existing cell
         assert(findItem(cellname, item, GetRootItem()));
         while (findItem(parentname, newparent, GetRootItem())) 
            copyItem(item,newparent);
         DeleteChildren(item);
         Delete(item);
         break;
      }   
      case 2: {//
         assert(findItem(cellname, item, GetRootItem()));
         while (findItem(parentname, newparent, GetRootItem())) 
            copyItem(item,newparent);
         break;
      }
      default: assert(false);
   }
}
示例#6
0
void browsers::CellBrowser::highlightChildren(wxTreeItemId parent, wxColour clr) {
   wxTreeItemIdValue cookie;
   SetItemTextColour(parent,clr);
   wxTreeItemId child = GetFirstChild(parent,cookie);
   while (child.IsOk()) {
      highlightChildren(child,clr);
      child = GetNextChild(parent,cookie);
   }   
}
bool CListProcess::TransferDataToWindow()
{
  wxString sTime;
  bool bStartTime = false;
  bool bStopTime = false;
  bool bRtn = true;
  bool bIsShown = IsShownOnScreen();
  if(bIsShown)
  {
    Show(false);
  }

  size_t n = m_pDirList->GetCount();
  long nItem;
  CDirEntry *pDirEntry;
  ClearAll();
  InsertColumn(ITEM_DIR,_T("Directory"),wxLIST_FORMAT_LEFT);
  InsertColumn(ITEM_START,_T("Start"),wxLIST_FORMAT_LEFT);
  InsertColumn(ITEM_STOP,_T("Stop"),wxLIST_FORMAT_LEFT);
  InsertColumn(ITEM_STATUS,_T("Status"),wxLIST_FORMAT_LEFT);
  for(size_t i = 0; (i < n) && bRtn; i++)
  {
    pDirEntry = m_pDirList->At(i);
    const wxString &sInput(pDirEntry->GetInputDir());
    const wxString &sStatus(pDirEntry->GetStatusString());
    nItem = InsertItem((long)i,sInput);
    sTime = pDirEntry->FormatStartTime();
    SetItem(nItem,ITEM_START,sTime);
    if(!sTime.IsEmpty())
    {
      bStartTime = true;
    }

    sTime = pDirEntry->FormatStopTime();
    SetItem(nItem,ITEM_STOP,sTime);
    if(!sTime.IsEmpty())
    {
      bStopTime = true;
    }
    SetItem(nItem,ITEM_STATUS,sStatus);
    SetItemTextColour(nItem,pDirEntry->GetStatusColour());
  }
  SetColumnWidth(ITEM_DIR,wxLIST_AUTOSIZE );
#define HEADER_SIZE 80
  SetColumnWidth(ITEM_START,bStartTime ? wxLIST_AUTOSIZE : HEADER_SIZE);
  SetColumnWidth(ITEM_STOP,bStopTime ? wxLIST_AUTOSIZE : HEADER_SIZE);
#undef HEADER_SIZE
  SetColumnWidth(ITEM_STATUS,wxLIST_AUTOSIZE );
  if(bIsShown)
  {
    Show(true);
  }
  Refresh();
  return bRtn;
}
void CListProcess::UpdateStatus(int nItem)
{
  wxString sTime;
  bool bStartTime = false;
  bool bStopTime = false;
  long nMin;
  long nMax;
  long nCount = (long) m_pDirList->GetCount();
  if(nItem >= 0)
  {
    nMin = (long) nItem;
    nMax = nMin;
    nMax++;
    if(nMax > nCount)
    {
      nMax = nCount;
    }
  }
  else
  {
    nMin = 0;
    nMax = nCount;
  }
  wxListItem info;
  CDirEntry *pDirEntry;
  for(long i = nMin; i < nMax; i++)
  {
    pDirEntry = m_pDirList->At((size_t)i);
    const wxString &sStatus(pDirEntry->GetStatusString());
    sTime = pDirEntry->FormatStartTime();
    SetItem(i,ITEM_START,sTime);
    if(!sTime.IsEmpty())
    {
      bStartTime = true;
    }
    sTime = pDirEntry->FormatStopTime();
    SetItem(i,ITEM_STOP,sTime);
    if(!sTime.IsEmpty())
    {
      bStopTime = true;
    }
    SetItem(i,ITEM_STATUS,sStatus);
    SetItemTextColour(i,pDirEntry->GetStatusColour());
  }
  if(bStartTime)
  {
    SetColumnWidth(ITEM_START,wxLIST_AUTOSIZE );
  }
  if(bStopTime)
  {
    SetColumnWidth(ITEM_STOP,wxLIST_AUTOSIZE );
  }
  SetColumnWidth(ITEM_STATUS,wxLIST_AUTOSIZE);
//  Refresh();
}
示例#9
0
void browsers::TDTbrowser::OnTELLopencell(wxString open_cell) {
   wxTreeItemId item;
   assert(findItem(open_cell, item, GetRootItem()));
   highlightChlidren(GetRootItem(), *wxLIGHT_GREY);
//   if (top_structure.IsOk())
//      SetItemFont(active_structure,_llfont_normal);
   top_structure = active_structure = item;
   highlightChlidren(top_structure, *wxBLACK);
   SetItemTextColour(active_structure,*wxBLUE);
//   SetItemFont(active_structure,_llfont_bold);
}
示例#10
0
void browsers::TDTbrowser::collectInfo(const wxString libname, laydata::TDTHierTree* tdtH) {
   AddRoot(libname);
   if (!tdtH) return; // new, empty design 
   laydata::TDTHierTree* root = tdtH->GetFirstRoot();
   wxTreeItemId nroot;
   while (root){
      nroot = AppendItem(GetRootItem(), wxString(root->GetItem()->name().c_str()));
      SetItemTextColour(nroot,*wxLIGHT_GREY);
      collectChildren(root, nroot);
      root = root->GetNextRoot();
   }
}
示例#11
0
void browsers::TDTbrowser::collectChildren(laydata::TDTHierTree *root, wxTreeItemId& lroot) {
   laydata::TDTHierTree* Child= root->GetChild();
   wxTreeItemId nroot;
   while (Child) {
      SetItemImage(lroot,0,wxTreeItemIcon_Normal);
      SetItemImage(lroot,1,wxTreeItemIcon_Expanded);
      nroot = AppendItem(lroot, wxString(Child->GetItem()->name().c_str()));
      SetItemTextColour(nroot,*wxLIGHT_GREY);
      collectChildren(Child, nroot);
      Child = Child->GetBrother();
	}
}
示例#12
0
wxTreeItemId CocaSystemTree::add( const coca::INode& node, wxTreeItemId parentId )
{
    if ( !parentId.IsOk() ) { return parentId; }

    wxTreeItemId id = AppendItem( parentId, EditorTools::getName( node ), EditorTools::getImageIndex( node ),
                                  -1, new ItemData( node ) );
    SetItemTextColour( id, EditorTools::getTextColour( node ) );

    addChildren( node, id );

    return id;
}
示例#13
0
void SessionTreeControl::unrotateVideoSessions()
{
    wxTreeItemId current = findSession( availableVideoNodeID,
            sessionManager->getCurrentRotateSessionAddress() );
    if ( current.IsOk() )
    {
        SetItemBackgroundColour( current, *wxBLUE );
        SetItemTextColour( current, *wxBLACK );
    }

    sessionManager->unrotate( false );
}
示例#14
0
void SessionTreeControl::rotateToVideoSession( std::string addr, bool fromAuto )
{
    if ( !sessionManager->rotateTo( addr, false ) )
    {
        gravUtil::logVerbose( "SessionTreeControl::rotateTo %s failed\n",
                                addr.c_str() );
        return;
    }

    wxTreeItemId current = findSession( availableVideoNodeID,
            sessionManager->getCurrentRotateSessionAddress() );
    wxTreeItemId last = findSession( availableVideoNodeID,
            sessionManager->getLastRotateSessionAddress() );

    if ( last.IsOk() )
    {
        SetItemBackgroundColour( last, *wxBLUE );
        SetItemTextColour( last, *wxBLACK );
    }
    if ( current.IsOk() )
    {
        if ( sessionManager->isInFailedState(
                sessionManager->getCurrentRotateSessionAddress(),
                AVAILABLEVIDEOSESSION ) )
        {
            SetItemBackgroundColour( current, *wxRED );
        }
        else
        {
            SetItemBackgroundColour( current, *wxWHITE );
            SetItemTextColour( current, *wxBLUE );
        }
    }

    // if manually rotated & currently autorotating, stop autorotating
    if ( !fromAuto && timer->IsRunning() )
    {
        toggleAutomaticRotate();
    }
}
示例#15
0
void wxSTEditorTreeCtrl::OnSTEState(wxSTEditorEvent &event)
{
    event.Skip();

    if ( event.HasStateChange(STE_MODIFIED) &&
        (event.GetEditor() != NULL) &&
        (event.GetEditor()->GetTreeItemData() != NULL) &&
        (event.GetEditor()->GetTreeItemData()->m_id))
    {
        SetItemTextColour(event.GetEditor()->GetTreeItemData()->m_id, event.GetEditor()->IsModified() ? *wxRED : *wxBLACK);
    }
    else if ( event.HasStateChange(STE_FILENAME | STE_MODIFIED | STE_EDITABLE) )
        UpdateFromNotebook();
}
示例#16
0
void browsers::CellBrowser::copyItem(const wxTreeItemId item, const wxTreeItemId newparent) {
   wxTreeItemId newitem = AppendItem(newparent, GetItemText(item));
   SetItemImage(newitem, GetItemImage(item,wxTreeItemIcon_Normal), wxTreeItemIcon_Normal);
   SetItemImage(newitem, GetItemImage(item,wxTreeItemIcon_Expanded), wxTreeItemIcon_Expanded);
   SetItemImage(newparent,0,wxTreeItemIcon_Normal);
   SetItemImage(newparent,1,wxTreeItemIcon_Expanded);
   SetItemTextColour(newitem, GetItemTextColour(newparent));
   wxTreeItemIdValue cookie;
   wxTreeItemId child = GetFirstChild(item,cookie);
   while (child.IsOk()) {
      copyItem(child, newitem);
      child = GetNextChild(item,cookie);
   }
}
示例#17
0
// Our variation of InsertItem, so we can do magical things!
long wxAdvancedListCtrl::ALCInsertItem(const wxString &Text)
{
    wxListItem ListItem;

    ListItem.m_itemId = InsertItem(GetItemCount(), Text, -1);

    ColourListItem(ListItem.m_itemId);

    SetItem(ListItem);

    // wxWidgets bug: Required for sorting colours correctly
    SetItemTextColour(ListItem.m_itemId, GetTextColour());

    return ListItem.m_itemId;
}
示例#18
0
void CFriendListCtrl::UpdateFriend(CFriend* toupdate)
{
	if (!toupdate) {
		return;
	}

	sint32 itemnr = FindItem(-1, reinterpret_cast<wxUIntPtr>(toupdate));
	if (itemnr == -1) {
		itemnr = InsertItem(GetItemCount(), wxEmptyString);
		SetItemPtrData(itemnr, reinterpret_cast<wxUIntPtr>(toupdate));
	}

	SetItem(itemnr, 0, toupdate->GetName());
	SetItemTextColour(itemnr, toupdate->GetLinkedClient().IsLinked() ? *wxBLUE : *wxBLACK);
}
示例#19
0
void CocaSystemTree::updateState( wxTreeItemId id )
{
    if ( !id.IsOk() ) { return; }

    const coca::INode* node = getNode( id );
    if ( !node ) { return; }

    SetItemImage( id, EditorTools::getImageIndex( *node ) );
    SetItemTextColour( id, EditorTools::getTextColour( *node ) );

    /*if ( updateChildren )
    {
        wxTreeItemIdValue cookie = 0;
        id = GetFirstChild( id, cookie );
        for ( ; id.IsOk(); id = GetNextSibling( id ) )
        {
            updateState( id, updateChildren );
        }
    }*/
}
void MadHighlightingDialog::SetAttrFC(const wxColor &color, const wxString &colorname)
{
    KeywordInfo &kinfo=g_KeywordInfoTable[g_Index];
    if(g_Index==0)
    {
        SetItemTextColour(WxListCtrlFC, 0, color);
        kinfo.attr->color=color;
    }
    else
    {
        wxASSERT(kinfo.kind!=kindRange);
        if(colorname==wxT("(Automatic)"))
        {
            kinfo.attr->color=wxNullColour;
        }
        else
        {
            kinfo.attr->color=color;
        }
    }
    RepaintKeyword();
}
示例#21
0
void wxSTEditorTreeCtrl::UpdateFromNotebook()
{
    wxSTERecursionGuard guard(m_rGuard_UpdateFromNotebook);
    if (guard.IsInside()) return;

    wxSTEditorNotebook *noteBook = GetSTEditorNotebook();
    if (!noteBook)
        return;

    int n;
    int page_count = noteBook->GetPageCount();
    int note_sel   = noteBook->GetSelection();

    wxTreeItemId id, selId;

    // Check for and add a root item to the treectrl, it's hidden
    wxTreeItemId rootId = GetRootItem();
    if (!rootId)
        rootId = AddRoot(_("Root"), -1, -1, NULL);

    // Check for and add a "Opened files" item to the treectrl
    wxArrayString openedfilesPath; openedfilesPath.Add(_("Opened files"));
    wxTreeItemId openedId = FindOrInsertItem(openedfilesPath, STE_TREECTRL_FIND_OR_INSERT);

    wxLongToLongHashMap windowToSTETreeItemDataMap = m_windowToSTETreeItemDataMap;

    Freeze();

    for (n = 0; n < page_count; n++)
    {
        id = wxTreeItemId(); // start fresh

        wxSTEditor* editor = noteBook->GetEditor(n);
        wxWindow* notePage = noteBook->GetPage(n);
        wxSTETreeItemData* steTreeItemData = NULL;

        // If this editor was already added to the tree, check if it's still correct
        if (editor && editor->GetTreeItemData())
        {
            // get and check the old tree item id, the filename/path could have changed
            steTreeItemData = editor->GetTreeItemData();

            if (steTreeItemData)
                id = steTreeItemData->m_id;

            if (steTreeItemData)
            {
                if ((steTreeItemData->m_notePage == notePage) &&
                    (steTreeItemData->m_fileName == editor->GetFileName()))
                {
                    // the page didn't change name, but do resync page number
                    steTreeItemData->m_page_num = n;
                    windowToSTETreeItemDataMap.erase((long)notePage);
                }
                else
                    steTreeItemData = NULL;
            }

            // Something changed, redo it
            if (id && !steTreeItemData)
            {
                // Erase refs to this page, we will recreate it
                m_windowToSTETreeItemDataMap.erase((long)notePage);
                windowToSTETreeItemDataMap.erase((long)notePage);
                DeleteItem(id, true, -1, openedId);

                // null it and add it correctly later
                id = wxTreeItemId();
                editor->SetTreeItemData(NULL);
            }
        }

        bool modified = editor->IsModified();

        if (!id)
        {
            // Create new data to add to the wxTreeItem
            steTreeItemData = new wxSTETreeItemData(n, notePage);

            // Only connect the destroy handler once
            if (m_windowDestroyMap.find((long)notePage) == m_windowDestroyMap.end())
            {
                m_windowDestroyMap[(long)notePage] = 1;

                notePage->Connect(wxID_ANY, wxEVT_DESTROY,
                                  wxWindowDestroyEventHandler(wxSTEditorTreeCtrl::OnWindowDestroy),
                                  NULL, this);
            }

            if (editor)
            {
                modified = editor->IsModified();
                steTreeItemData->m_root = _("Opened files");
                steTreeItemData->m_fileName = editor->GetFileName();
                wxFileName fn(steTreeItemData->m_fileName);

                // Don't need to Normalize() since it is done in wxSTEditor::SetFilename()
                //if (fn.FileExists()) fn.Normalize();

                switch (m_display_type)
                {
                    case SHOW_FILENAME_ONLY :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                        steTreeItemData->m_treePath.Add(fn.GetFullName());
                        break;
                    }
                    case SHOW_FILEPATH_ONLY :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                        steTreeItemData->m_treePath.Add(fn.GetFullPath());
                        break;
                    }
                    case SHOW_PATH_THEN_FILENAME :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                        steTreeItemData->m_treePath.Add(fn.GetPath());
                        steTreeItemData->m_treePath.Add(fn.GetFullName());
                        break;
                    }
                    case SHOW_ALL_PATHS :
                    {
                        steTreeItemData->m_treePath.Add(steTreeItemData->m_root);

                        wxArrayString dirs = fn.GetDirs();
                        for (size_t i = 0; i < dirs.GetCount(); ++i)
                            steTreeItemData->m_treePath.Add(dirs[i]);

                        steTreeItemData->m_treePath.Add(fn.GetFullName());
                        break;
                    }
                }
            }
            else
            {
                steTreeItemData->m_root = _("Others");
                steTreeItemData->m_fileName = noteBook->GetPageText(n);

                steTreeItemData->m_treePath.Add(steTreeItemData->m_root);
                steTreeItemData->m_treePath.Add(steTreeItemData->m_fileName.GetFullPath());
            }

            // Always insert a new editor since if we already did, it'd have a treeitem id.
            // For other windows, who knows, you can only have one tree node per notebook page name
            if (editor)
            {
                id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_INSERT);
                SetItemImage(id, STE_TREECTRL_IMAGE_EDITOR);
                editor->SetTreeItemData(steTreeItemData);
                steTreeItemData->m_steRefData = editor->GetSTERefData();
            }
            else
            {
                id = FindOrInsertItem(steTreeItemData->m_treePath, STE_TREECTRL_FIND_OR_INSERT);
                SetItemImage(id, STE_TREECTRL_IMAGE_OTHER);
            }

            // must set new data before deleting old in MSW since it checks old before setting new
            wxTreeItemData* oldData = GetItemData(id);
            steTreeItemData->m_id = id;
            SetItemData(id, steTreeItemData);
            if (oldData) delete oldData;

            m_windowToSTETreeItemDataMap[(long)notePage] = (long)steTreeItemData;
        }

        // we should have valid id at this point
        if (n == note_sel)
            selId = id;
        else if (IsBold(id))
            SetItemBold(id, false);

        SetItemTextColour(id, modified ? *wxRED : *wxBLACK);
    }

    wxLongToLongHashMap::iterator it;
    for( it = windowToSTETreeItemDataMap.begin(); it != windowToSTETreeItemDataMap.end(); ++it )
    {
        wxSTETreeItemData* oldData = (wxSTETreeItemData*)it->second;
        DeleteItem(oldData->m_id, true, -1, openedId);
        m_windowToSTETreeItemDataMap.erase(it->first);
    }

    if (selId)
    {
        SetItemBold(selId);
        SelectItem(selId);
    }

    SortAllChildren(GetRootItem());
    Thaw();
}
示例#22
0
void CGameListCtrl::Update()
{
	int scrollPos = wxWindow::GetScrollPos(wxVERTICAL);
	// Don't let the user refresh it while a game is running
	if (Core::GetState() != Core::CORE_UNINITIALIZED)
		return;

	if (m_imageListSmall)
	{
		delete m_imageListSmall;
		m_imageListSmall = NULL;
	}

	// NetPlay : Set/Reset the GameList string
	m_gameList.clear();
	m_gamePath.clear();

	Hide();

	ScanForISOs();

	ClearAll();

	if (m_ISOFiles.size() != 0)
	{
		// Don't load bitmaps unless there are games to list
		InitBitmaps();

		// add columns
		InsertColumn(COLUMN_DUMMY,_T(""));
		InsertColumn(COLUMN_PLATFORM, _T(""));
		InsertColumn(COLUMN_BANNER, _("Banner"));
		InsertColumn(COLUMN_TITLE, _("Title"));

		// Instead of showing the notes + the company, which is unknown with
		// wii titles We show in the same column : company for GC games and
		// description for wii/wad games
		InsertColumn(COLUMN_NOTES, _("Notes"));
		InsertColumn(COLUMN_COUNTRY, _T(""));
		InsertColumn(COLUMN_SIZE, _("Size"));
		InsertColumn(COLUMN_EMULATION_STATE, _("State"));

#ifdef __WXMSW__
		const int platform_padding = 0;
#else
		const int platform_padding = 8;
#endif
		
		// set initial sizes for columns
		SetColumnWidth(COLUMN_DUMMY,0);
		SetColumnWidth(COLUMN_PLATFORM, 35 + platform_padding);
		SetColumnWidth(COLUMN_BANNER, 96 + platform_padding);
		SetColumnWidth(COLUMN_TITLE, 200 + platform_padding);
		SetColumnWidth(COLUMN_NOTES, 200 + platform_padding);
		SetColumnWidth(COLUMN_COUNTRY, 32 + platform_padding);
		SetColumnWidth(COLUMN_EMULATION_STATE, 50 + platform_padding);

		// add all items
		for (int i = 0; i < (int)m_ISOFiles.size(); i++)
		{
			InsertItemInReportView(i);
			if (m_ISOFiles[i]->IsCompressed())
				SetItemTextColour(i, wxColour(0xFF0000));
		}

		// Sort items by Title
		if (!sorted)
			last_column = 0;
		sorted = false;
		wxListEvent event;
		event.m_col = SConfig::GetInstance().m_ListSort2;
		OnColumnClick(event);

		event.m_col = SConfig::GetInstance().m_ListSort;
		OnColumnClick(event);
		sorted = true;

		SetColumnWidth(COLUMN_SIZE, wxLIST_AUTOSIZE);
	}
	else
	{
		wxString errorString;
		// We just check for one hide setting to be enabled, as we may only
		// have GC games for example, and hide them, so we should show the
		// second message instead
		if ((SConfig::GetInstance().m_ListGC  &&
			SConfig::GetInstance().m_ListWii  &&
			SConfig::GetInstance().m_ListWad) &&
			(SConfig::GetInstance().m_ListJap &&
			SConfig::GetInstance().m_ListUsa  &&
			SConfig::GetInstance().m_ListPal))
		{
			errorString = _("Dolphin could not find any GC/Wii ISOs.  Doubleclick here to browse for files...");
		}
		else
		{
			errorString = _("Dolphin is currently set to hide all games.  Doubleclick here to show all games...");
		}
		InsertColumn(0, _("No ISOs or WADS found"));
		long index = InsertItem(0, errorString);
		SetItemFont(index, *wxITALIC_FONT);
		SetColumnWidth(0, wxLIST_AUTOSIZE);
	}
	if (GetSelectedISO() == NULL)
		main_frame->UpdateGUI();
	Show();

	AutomaticColumnWidth();
	ScrollLines(scrollPos);
	SetFocus();
}
示例#23
0
文件: cmpctrl.cpp 项目: DDMAL/aruspix
void CmpCtrl::Update( )
{
    wxASSERT( m_cmpFilePtr );
    wxASSERT( m_cmpEnvPtr );
    
    wxTreeItemId id;
    AxTreeItem *axTreeItem = NULL;
	int i, j;
	
	DeleteChildren( m_booksId );
    int books = (int)m_cmpFilePtr->m_bookFiles.GetCount();
    if ( books > 0 )
        SetItemText( m_booksId, wxString::Format( _("Books (%d)"), books ) );
    else
        SetItemText( m_booksId, _("Books") );
    // For specific menu
    axTreeItem = new AxTreeItem( m_booksId, CMP_TREE_BOOKS, NULL ); 
    m_axItems.Add( axTreeItem );
    
    for ( i = 0; i < books; i++)
    {
		RecBookFile *book = m_cmpFilePtr->m_bookFiles[i].m_recBookFilePtr;
        wxTreeItemId m_bookId = AppendItem( m_booksId, m_cmpFilePtr->m_bookFiles[i].m_shortname );
		SetTypeImages( m_bookId, IMG_FOLDER );
		
        // The name of the book
        AppendItem( m_bookId, m_cmpFilePtr->m_bookFiles[i].m_bookname, IMG_TEXT, IMG_TEXT_S );
        
        // The Aruspix files of the book
        m_cmpFilePtr->m_bookFiles[i].m_axFilesId = AppendItem( m_bookId, _("Aruspix files") );
		SetTypeImages( m_cmpFilePtr->m_bookFiles[i].m_axFilesId, IMG_FOLDER );        
		int ax = (int)book->m_axFiles.GetCount();
		if ( ax > 0 )
			SetItemText( m_cmpFilePtr->m_bookFiles[i].m_axFilesId, wxString::Format( _("Aruspix files (%d)"), ax ) );
		else
			SetItemText( m_cmpFilePtr->m_bookFiles[i].m_axFilesId, _("Aruspix files") );
		for ( j = 0; j < ax; j++)
		{
			id = AppendItem( m_cmpFilePtr->m_bookFiles[i].m_axFilesId, book->m_axFiles[j].m_filename, IMG_AXZ, IMG_AXZ_S );
			if (  book->m_axFiles[j].m_flags & FILE_DESACTIVATED ) 
				SetItemTextColour( id , *wxLIGHT_GREY );
			if ( !wxFileExists( book->m_axFileDir + wxFileName::GetPathSeparator() +  book->m_axFiles[j].m_filename ) ) 
				SetItemTextColour( id , *wxRED );
			else if ( RecFile::IsRecognized( book->m_axFileDir + wxFileName::GetPathSeparator() +  book->m_axFiles[j].m_filename ) )
			{
				SetItemImage( id, IMG_AXZ_OK ); 
				SetItemImage( id, IMG_AXZ_OK_S,  wxTreeItemIcon_Selected );
                axTreeItem = new AxTreeItem( id, CMP_TREE_BOOK_AXFILE, &m_cmpFilePtr->m_bookFiles[i] ); 
                m_axItems.Add( axTreeItem );
			}	
		}
		
        // The parts of the book
		m_cmpFilePtr->m_bookFiles[i].m_partsId = AppendItem( m_bookId, _("Parts") );
		SetTypeImages( m_cmpFilePtr->m_bookFiles[i].m_partsId, IMG_FOLDER );
        // for the parts we associate the book object
        axTreeItem = new AxTreeItem( m_cmpFilePtr->m_bookFiles[i].m_partsId, CMP_TREE_BOOK_PARTS, &m_cmpFilePtr->m_bookFiles[i] ); 
        m_axItems.Add( axTreeItem );
        // We have a separate method for this
        UpdateParts( &m_cmpFilePtr->m_bookFiles[i] );
    }
	
    DeleteChildren( m_cmpId );
    int collations = (int)m_cmpFilePtr->m_collations.GetCount();
    if ( collations > 0 )
        SetItemText( m_cmpId, wxString::Format( _("Collations (%d)"), collations ) );
    else
        SetItemText( m_cmpId, _("Collations") );
    // For specific menu
    axTreeItem = new AxTreeItem( m_cmpId, CMP_TREE_COLLATIONS, NULL ); 
    m_axItems.Add( axTreeItem );
    
    for ( i = 0; i < collations; i++)
    {
		//RecBookFile *book = m_cmpFilePtr->m_bookFiles[i].m_recBookFilePtr;
		m_cmpFilePtr->m_collations[i].m_colId = AppendItem( m_cmpId, m_cmpFilePtr->m_collations[i].m_name );
		SetTypeImages( m_cmpFilePtr->m_collations[i].m_colId, IMG_FOLDER );
        // for the parts we associate the collation object
        axTreeItem = new AxTreeItem( m_cmpFilePtr->m_collations[i].m_colId, CMP_TREE_COLLATION, &m_cmpFilePtr->m_collations[i] ); 
        m_axItems.Add( axTreeItem );
        // We have a separate method for this
        UpdateCollationParts( &m_cmpFilePtr->m_collations[i] );
	}
	
    m_cmpFilePtr->Modify();
}
/*
 * WxListCtrlKeywordSelected
 */
void MadHighlightingDialog::WxListCtrlKeywordSelected(wxListEvent& event)
{
    long oldIndex=g_Index;
    g_Index = event.m_itemIndex;

    WxListCtrlKeyword->Freeze();
    WxListCtrlFC->Freeze();

    if(oldIndex!=g_Index)
    {
        wxString str;
        if(oldIndex>=0)
        {
            str = WxListCtrlKeyword->GetItemText(oldIndex);
            if(str[0]==wxT('*')) 
            {
                WxListCtrlKeyword->SetItemText(oldIndex, str.Right(str.Len()-1));
            }
        }

        str = WxListCtrlKeyword->GetItemText(g_Index);
        WxListCtrlKeyword->SetItemText(g_Index, wxString(wxT('*'))+str);

        WxListCtrlKeyword->SetColumnWidth(0, WxListCtrlKeyword->GetClientSize().x - 4);
    }

    KeywordInfo &kinfo=g_KeywordInfoTable[g_Index];
    if(g_Index==0) // set (Automatic) colors
    {
        SetItemTextColour(WxListCtrlFC, 0, kinfo.attr->color);
        int c = (kinfo.attr->bgcolor.Red()+kinfo.attr->bgcolor.Green()+kinfo.attr->bgcolor.Blue())/3;
        if(c >= 128)
        {
            SetItemColour(WxListCtrlBC, 0, *wxBLACK, kinfo.attr->bgcolor);
        }
        else
        {
            SetItemColour(WxListCtrlBC, 0, *wxWHITE, kinfo.attr->bgcolor);
        }
    }

    wxColour bgc;
    switch(kinfo.kind)
    {
    case kindSysAttr1:
    case kindKeyword:
        WxCheckBoxBold->Enable();
        WxCheckBoxItalic->Enable();
        WxCheckBoxUnderline->Enable();
        WxCheckBoxBold->SetValue((kinfo.attr->style&fsBold)!=0);
        WxCheckBoxItalic->SetValue((kinfo.attr->style&fsItalic)!=0);
        WxCheckBoxUnderline->SetValue((kinfo.attr->style&fsUnderline)!=0);
        SetPanelFC(kinfo.attr->color);
        SetPanelBC(kinfo.attr->bgcolor);
        WxListCtrlFC->Enable();
        WxButtonFC->Enable();
        WxListCtrlBC->Enable();
        WxButtonBC->Enable();
        bgc=kinfo.attr->bgcolor;
        break;
    case kindSysAttr2:
        WxCheckBoxBold->SetValue(false);
        WxCheckBoxItalic->SetValue(false);
        WxCheckBoxUnderline->SetValue(false);
        WxCheckBoxBold->Disable();
        WxCheckBoxItalic->Disable();
        WxCheckBoxUnderline->Disable();
        SetPanelFC(kinfo.attr->color);
        SetPanelBC(wxNullColour);
        WxListCtrlFC->Enable();
        WxButtonFC->Enable();
        WxListCtrlBC->Disable();
        WxButtonBC->Disable();
        bgc==wxNullColour;
        break;
    case kindRange:
        WxCheckBoxBold->SetValue(false);
        WxCheckBoxItalic->SetValue(false);
        WxCheckBoxUnderline->SetValue(false);
        WxCheckBoxBold->Disable();
        WxCheckBoxItalic->Disable();
        WxCheckBoxUnderline->Disable();
        SetPanelFC(wxNullColour);
        SetPanelBC(*kinfo.range_bgcolor);
        WxListCtrlFC->Disable();
        WxButtonFC->Disable();
        WxListCtrlBC->Enable();
        WxButtonBC->Enable();
        bgc=*kinfo.range_bgcolor;
        break;
    }
    if(bgc==wxNullColour) bgc=g_KeywordInfoTable[0].attr->bgcolor;
    WxListCtrlFC->SetBackgroundColour(bgc);
    SetItemBackgroundColour(WxListCtrlFC, 0, bgc);
    this->Layout();

    WxListCtrlKeyword->SetItemState(event.m_itemIndex, 0, wxLIST_STATE_SELECTED);
    WxListCtrlKeyword->Thaw();
    WxListCtrlFC->Thaw();
}
示例#25
0
void wxGxTreeViewBase::AddTreeItem(wxGxObject* pGxObject, wxTreeItemId hParent)
{
	if(NULL == pGxObject)
		return;

    wxTreeItemId TreeItemId = m_TreeMap[pGxObject->GetId()];
	if(TreeItemId.IsOk())
        return;

	IGxObjectUI* pObjUI =  dynamic_cast<IGxObjectUI*>(pGxObject);
	wxIcon icon;
	if(pObjUI != NULL)
		icon = pObjUI->GetSmallImage();

	int pos(wxNOT_FOUND);
	if(icon.IsOk())
    {
        for(size_t i = 0; i < m_IconsArray.size(); ++i)
        {
            if(m_IconsArray[i].oIcon.IsSameAs(icon))
            {
                pos = m_IconsArray[i].iImageIndex;
                break;
            }
        }
        if(pos == wxNOT_FOUND)
        {
            pos = m_TreeImageList.Add(icon);
            ICONDATA myicondata = {icon, pos};
            m_IconsArray.push_back(myicondata);
        }
    }
	else
		pos = 0;//m_ImageListSmall.Add(m_ImageListSmall.GetIcon(2));//0 col img, 1 - col img

	wxGxTreeItemData* pData = new wxGxTreeItemData(pGxObject->GetId(), pos, false);
    
    IGxObjectTreeAttr* pGxObjectAttr = dynamic_cast<IGxObjectTreeAttr*>(pGxObject);

    wxString sName;
    if(m_pCatalog->GetShowExt())
        sName = pGxObject->GetName();
    else
        sName = pGxObject->GetBaseName();

    if(pGxObjectAttr && pGxObjectAttr->ShowCount())
    {
        sName.Append(wxString::Format(wxT(" [%d]"), pGxObjectAttr->GetCount()));
    }


	wxTreeItemId NewTreeItem = AppendItem(hParent, sName, pos, wxNOT_FOUND, pData);
	m_TreeMap[pGxObject->GetId()] = NewTreeItem;

	wxGxObjectContainer* pContainer = wxDynamicCast(pGxObject, wxGxObjectContainer);//dynamic_cast<IGxObjectContainer*>(pGxObject);
	if(pContainer != NULL)
    {
		if(pContainer->AreChildrenViewable())
			SetItemHasChildren(NewTreeItem);
    }

    if(pGxObjectAttr)
    {
        SetItemBold(NewTreeItem, pGxObjectAttr->IsBold());
        SetItemTextColour(NewTreeItem, pGxObjectAttr->GetColor());                    
    }

    //SortChildren(hParent);
	wxTreeCtrl::Refresh();
}
示例#26
0
void CGameListCtrl::Update()
{
	int scrollPos = wxWindow::GetScrollPos(wxVERTICAL);
	// Don't let the user refresh it while a game is running
	if (Core::GetState() != Core::CORE_UNINITIALIZED)
		return;

	if (m_imageListSmall)
	{
		delete m_imageListSmall;
		m_imageListSmall = nullptr;
	}

	Hide();

	ScanForISOs();

	ClearAll();

	if (m_ISOFiles.size() != 0)
	{
		// Don't load bitmaps unless there are games to list
		InitBitmaps();

		// add columns
		InsertColumn(COLUMN_DUMMY, "");
		InsertColumn(COLUMN_PLATFORM, "");
		InsertColumn(COLUMN_BANNER, _("Banner"));
		InsertColumn(COLUMN_TITLE, _("Title"));

		InsertColumn(COLUMN_MAKER, _("Maker"));
		InsertColumn(COLUMN_FILENAME, _("File"));
		InsertColumn(COLUMN_ID, _("ID"));
		InsertColumn(COLUMN_COUNTRY, "");
		InsertColumn(COLUMN_SIZE, _("Size"));
		InsertColumn(COLUMN_EMULATION_STATE, _("State"));

#ifdef __WXMSW__
		const int platform_padding = 0;
#else
		const int platform_padding = 8;
#endif

		const int platform_icon_padding = 1;

		// set initial sizes for columns
		SetColumnWidth(COLUMN_DUMMY, 0);
		SetColumnWidth(COLUMN_PLATFORM, SConfig::GetInstance().m_showSystemColumn ? 32 + platform_icon_padding + platform_padding : 0);
		SetColumnWidth(COLUMN_BANNER, SConfig::GetInstance().m_showBannerColumn ? 96 + platform_padding : 0);
		SetColumnWidth(COLUMN_TITLE, 175 + platform_padding);
		SetColumnWidth(COLUMN_MAKER, SConfig::GetInstance().m_showMakerColumn ? 150 + platform_padding : 0);
		SetColumnWidth(COLUMN_FILENAME, SConfig::GetInstance().m_showFileNameColumn ? 100 + platform_padding : 0);
		SetColumnWidth(COLUMN_ID, SConfig::GetInstance().m_showIDColumn ? 75 + platform_padding : 0);
		SetColumnWidth(COLUMN_COUNTRY, SConfig::GetInstance().m_showRegionColumn ? 32 + platform_padding : 0);
		SetColumnWidth(COLUMN_EMULATION_STATE, SConfig::GetInstance().m_showStateColumn ? 48 + platform_padding : 0);

		// add all items
		for (int i = 0; i < (int)m_ISOFiles.size(); i++)
		{
			InsertItemInReportView(i);
			if (SConfig::GetInstance().m_ColorCompressed && m_ISOFiles[i]->IsCompressed())
				SetItemTextColour(i, wxColour(0xFF0000));
		}

		// Sort items by Title
		if (!sorted)
			last_column = 0;
		sorted = false;
		wxListEvent event;
		event.m_col = SConfig::GetInstance().m_ListSort2;
		OnColumnClick(event);

		event.m_col = SConfig::GetInstance().m_ListSort;
		OnColumnClick(event);
		sorted = true;

		SetColumnWidth(COLUMN_SIZE, SConfig::GetInstance().m_showSizeColumn ? wxLIST_AUTOSIZE : 0);
	}
	else
	{
		wxString errorString;
		// We just check for one hide setting to be enabled, as we may only
		// have GC games for example, and hide them, so we should show the
		// first message instead
		if (IsHidingItems())
		{
			errorString = _("Dolphin is currently set to hide all games. Double-click here to show all games...");
		}
		else
		{
			errorString = _("Dolphin could not find any GameCube/Wii ISOs or WADs. Double-click here to set a games directory...");
		}
		InsertColumn(0, "");
		long index = InsertItem(0, errorString);
		SetItemFont(index, *wxITALIC_FONT);
		SetColumnWidth(0, wxLIST_AUTOSIZE);
	}
	if (GetSelectedISO() == nullptr)
		main_frame->UpdateGUI();
	Show();

	AutomaticColumnWidth();
	ScrollLines(scrollPos);
	SetFocus();
}
示例#27
0
void wxGxTreeViewBase::OnObjectChanged(wxGxCatalogEvent& event)
{
	wxTreeItemId TreeItemId = m_TreeMap[event.GetObjectID()];
	if(TreeItemId.IsOk())
	{
		wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(TreeItemId);
		if(pData != NULL)
		{
            wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
			IGxObjectUI* pGxObjectUI = dynamic_cast<IGxObjectUI*>(pGxObject);
			wxGxObjectContainer* pGxObjectContainer = dynamic_cast<wxGxObjectContainer*>(pGxObject);
            IGxObjectTreeAttr* pGxObjectAttr = dynamic_cast<IGxObjectTreeAttr*>(pGxObject);
			if(pGxObjectUI != NULL)
			{
                wxString sName;
                if(m_pCatalog->GetShowExt())
                    sName = pGxObject->GetName();
                else
                    sName = pGxObject->GetBaseName();

                if(pGxObjectAttr && pGxObjectAttr->ShowCount())
                {
                    sName.Append(wxString::Format(wxT(" [%d]"), pGxObjectAttr->GetCount()));
                }

				wxIcon icon = pGxObjectUI->GetSmallImage();

                int pos(wxNOT_FOUND);
				if(icon.IsOk())
                {
                    for(size_t i = 0; i < m_IconsArray.size(); ++i)
                    {
                        if(m_IconsArray[i].oIcon.IsSameAs(icon))
                        {
                            pos = m_IconsArray[i].iImageIndex;
                            break;
                        }
                    }
                    if(pos == wxNOT_FOUND)
                    {
                        pos = m_TreeImageList.Add(icon);
                        ICONDATA myicondata = {icon, pos};
                        m_IconsArray.push_back(myicondata);
                    }
                    SetItemImage(TreeItemId, pos);
					//m_TreeImageList.Replace(pData->m_smallimage_index, icon);
                }
				SetItemText(TreeItemId, sName);
				if(pGxObjectContainer != NULL)
				{
					wxBusyCursor wait;
					bool bItemHasChildren = pGxObjectContainer->HasChildren();
					if(ItemHasChildren(TreeItemId) && !bItemHasChildren)
					{						
						CollapseAndReset(TreeItemId);
						pData->m_bExpandedOnce = false;
                        UpdateGxSelection();
					}
					SetItemHasChildren(TreeItemId, bItemHasChildren && pGxObjectContainer->AreChildrenViewable());
				}
                
                if(pGxObjectAttr)
                {
                    SetItemBold(TreeItemId, pGxObjectAttr->IsBold());
                    SetItemTextColour(TreeItemId, pGxObjectAttr->GetColor());                    
                }
				//wxTreeCtrl::Refresh();
			}
		}
	}
}
示例#28
0
void MyTreeCtrl::RefreshTreeItems(Builder *pBuilder)
{
	VTLOG1("Refreshing Tree Items:");

	// Deleting the previous items can call OnSelChanged, which can cause VTB
	//  to forget the active layer, so indicate that this is not user input.
	m_bUser = false;
	DeleteAllItems();
	m_bUser = true;

	rootId = AddRoot(_("Layers"));
	SetItemBold(rootId);

	int	image, imageSel;

	wxTreeItemId elevId =	AddRootItem(MyTreeCtrl::TreeCtrlIcon_Grid, _("Elevation"));
	SetItemData(elevId, new MyTreeItemData(LT_ELEVATION));

	wxTreeItemId imageId =	AddRootItem(MyTreeCtrl::TreeCtrlIcon_Image, _("Images"));
	SetItemData(imageId, new MyTreeItemData(LT_IMAGE));

	wxTreeItemId buildId =	AddRootItem(MyTreeCtrl::TreeCtrlIcon_Building, _("Structures"));
	SetItemData(buildId, new MyTreeItemData(LT_STRUCTURE));

	wxTreeItemId roadId =	AddRootItem(MyTreeCtrl::TreeCtrlIcon_Road, _("Roads"));
	SetItemData(roadId, new MyTreeItemData(LT_ROAD));

	wxTreeItemId vegId =	AddRootItem(MyTreeCtrl::TreeCtrlIcon_Veg1, _("Vegetation"));
	SetItemData(vegId, new MyTreeItemData(LT_VEG));

	wxTreeItemId waterId =	AddRootItem(MyTreeCtrl::TreeCtrlIcon_Water, _("Water"));
	SetItemData(waterId, new MyTreeItemData(LT_WATER));

	wxTreeItemId utilityId = AddRootItem(MyTreeCtrl::TreeCtrlIcon_Utility, _("Utilities"));
	SetItemData(utilityId, new MyTreeItemData(LT_UTILITY));

	wxTreeItemId rawId =	AddRootItem(MyTreeCtrl::TreeCtrlIcon_Raw, _("Raw"));
	SetItemData(rawId, new MyTreeItemData(LT_RAW));

	image = TreeCtrlIcon_File;
	imageSel = TreeCtrlIcon_FileSelected;
	vtLayerPtr lp;
	int iLayers = 0;
	if (pBuilder) iLayers = pBuilder->NumLayers();
	wxTreeItemId hSelectedItem;
	for (int i = 0; i < iLayers; i++)
	{
		lp = pBuilder->GetLayer(i);

		wxString str = MakeItemName(lp);

		wxTreeItemId hItem;
		switch (lp->GetType())
		{
		case LT_ELEVATION:
			hItem = AppendItem(elevId, str, image, imageSel);
			break;
		case LT_IMAGE:
			hItem = AppendItem(imageId, str, image, imageSel);
			break;
		case LT_ROAD:
			hItem = AppendItem(roadId, str, image, imageSel);
			break;
		case LT_STRUCTURE:
			hItem = AppendItem(buildId, str, image, imageSel);
			break;
		case LT_VEG:
			hItem = AppendItem(vegId, str, image, imageSel);
			break;
		case LT_WATER:
			hItem = AppendItem(waterId, str, image, imageSel);
			break;
		case LT_UTILITY:
			hItem = AppendItem(utilityId, str, image, imageSel);
			break;
		case LT_RAW:
			hItem = AppendItem(rawId, str, image, imageSel);
			break;
		case LT_UNKNOWN:
		case LAYER_TYPES:
			// Keep picky compilers quiet.
			break;
		}
		if (hItem.IsOk())
		{
			SetItemData(hItem, new MyTreeItemData(lp));

			if (lp == pBuilder->GetActiveLayer())
				hSelectedItem = hItem;
			if (!lp->GetVisible())
			{
				SetItemFont(hItem, *wxITALIC_FONT);
				SetItemTextColour(hItem, wxColour(80,80,80));
			}
		}
	}
	VTLOG(" %d layers.\n", iLayers);

	// Expand the groups after they have all their items.  It doesn't work
	//  to expand before, because then not all items are shown.
	Expand(elevId);
	Expand(imageId);
	Expand(roadId);
	Expand(buildId);
	Expand(vegId);
	Expand(waterId);
	Expand(utilityId);
	Expand(rawId);

	// Wait until all the groups are expanded, before highlighting the
	//  selected item, so that it will definitely be in view.
	if (hSelectedItem.IsOk())
		SelectItem(hSelectedItem);
}
示例#29
0
void MyTreeCtrl::CreateButtonsImageList(int size)
{
    if ( size == -1 )
    {
        SetButtonsImageList(NULL);
        return;
    }

    // Make an image list containing small icons
    wxImageList *images = new wxImageList(size, size, true);

    // should correspond to TreeCtrlIcon_xxx enum
    wxBusyCursor wait;
    wxIcon icons[4];
    icons[0] = wxIcon(icon3_xpm);   // closed
    icons[1] = wxIcon(icon3_xpm);   // closed, selected
    icons[2] = wxIcon(icon5_xpm);   // open
    icons[3] = wxIcon(icon5_xpm);   // open, selected

    for ( size_t i = 0; i < WXSIZEOF(icons); i++ )
    {
        int sizeOrig = icons[i].GetWidth();
        if ( size == sizeOrig )
        {
            images->Add(icons[i]);
        }
        else
        {
            images->Add(wxBitmap(wxBitmap(icons[i]).ConvertToImage().Rescale(size, size)));
        }
    }

    AssignButtonsImageList(images);
#else
void MyTreeCtrl::CreateButtonsImageList(int WXUNUSED(size))
{
#endif
}

int MyTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
                               const wxTreeItemId& item2)
{
    if ( m_reverseSort )
    {
        // just exchange 1st and 2nd items
        return wxTreeCtrl::OnCompareItems(item2, item1);
    }
    else
    {
        return wxTreeCtrl::OnCompareItems(item1, item2);
    }
}

void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent,
                                     size_t numChildren,
                                     size_t depth,
                                     size_t folder)
{
    if ( depth > 0 )
    {
        bool hasChildren = depth > 1;

        wxString str;
        for ( size_t n = 0; n < numChildren; n++ )
        {
            // at depth 1 elements won't have any more children
            if ( hasChildren )
                str.Printf(wxT("%s child %u"), wxT("Folder"), unsigned(n + 1));
            else
                str.Printf(wxT("%s child %u.%u"), wxT("File"), unsigned(folder), unsigned(n + 1));

            // here we pass to AppendItem() normal and selected item images (we
            // suppose that selected image follows the normal one in the enum)
            int image, imageSel;
            if ( wxGetApp().ShowImages() )
            {
                image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder;
                imageSel = image + 1;
            }
            else
            {
                image = imageSel = -1;
            }
            wxTreeItemId id = AppendItem(idParent, str, image, imageSel,
                                         new MyTreeItemData(str));

            // and now we also set the expanded one (only for the folders)
            if ( hasChildren && wxGetApp().ShowImages() )
            {
                SetItemImage(id, TreeCtrlIcon_FolderOpened,
                             wxTreeItemIcon_Expanded);
            }

            // remember the last child for OnEnsureVisible()
            if ( !hasChildren && n == numChildren - 1 )
            {
                m_lastItem = id;
            }

            AddItemsRecursively(id, numChildren, depth - 1, n + 1);
        }
    }
    //else: done!
}

void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
                                    size_t depth)
{
    int image = wxGetApp().ShowImages() ? MyTreeCtrl::TreeCtrlIcon_Folder : -1;
    wxTreeItemId rootId = AddRoot(wxT("Root"),
                                  image, image,
                                  new MyTreeItemData(wxT("Root item")));
    if ( !HasFlag(wxTR_HIDE_ROOT) && image != -1 )
    {
        SetItemImage(rootId, TreeCtrlIcon_FolderOpened, wxTreeItemIcon_Expanded);
    }

    AddItemsRecursively(rootId, numChildren, depth, 0);

    // set some colours/fonts for testing
    if ( !HasFlag(wxTR_HIDE_ROOT) )
        SetItemFont(rootId, *wxITALIC_FONT);

    wxTreeItemIdValue cookie;
    wxTreeItemId id = GetFirstChild(rootId, cookie);
    SetItemTextColour(id, *wxBLUE);

    id = GetNextChild(rootId, cookie);
    id = GetNextChild(rootId, cookie);
    SetItemTextColour(id, *wxRED);
    SetItemBackgroundColour(id, *wxLIGHT_GREY);
}
示例#30
0
// Makes a row exchange places
void wxAdvancedListCtrl::FlipRow(long Row, long NextRow)
{
    if(Row == NextRow)
        return;

    // Retrieve data for the next item
    wxListItem Item1, Item2;
    wxListItem Item1Flipped, Item2Flipped;

    Item1.SetId(Row);
    Item1.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE);

    Item2.SetId(NextRow);
    Item2.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE);

    Item1Flipped.SetId(NextRow);
    Item1Flipped.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA
                         | wxLIST_MASK_IMAGE);

    Item2Flipped.SetId(Row);
    Item2Flipped.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA
                         | wxLIST_MASK_IMAGE);

    // Due to bugs/limitations with wxWidgets, certain stuff needs to be
    // physically taken from the list control as GetItem is finicky
    wxColour Item1Colour = GetItemTextColour(Row);
    wxColour Item2Colour = GetItemTextColour(NextRow);
    wxInt32 Item1State = GetItemState(Row, wxLIST_STATE_SELECTED
                                      | wxLIST_STATE_FOCUSED);
    wxInt32 Item2State = GetItemState(NextRow, wxLIST_STATE_SELECTED
                                      | wxLIST_STATE_FOCUSED);

    // Flip the data for columns.
    for (wxInt32 ColumnCounter = 0;
            ColumnCounter < GetColumnCount();
            ++ColumnCounter)
    {
        Item1.SetColumn(ColumnCounter);
        GetItem(Item1);

        Item2.SetColumn(ColumnCounter);
        GetItem(Item2);

        // Do the flip
        // Set data for the first item
        Item2Flipped.SetImage(Item2.GetImage());
        Item2Flipped.SetData(Item2.GetData());
        Item2Flipped.SetText(Item2.GetText());

        // Now the second
        Item1Flipped.SetImage(Item1.GetImage());
        Item1Flipped.SetData(Item1.GetData());
        Item1Flipped.SetText(Item1.GetText());

        // Set them
        Item1Flipped.SetColumn(ColumnCounter);
        SetItem(Item1Flipped);

        Item2Flipped.SetColumn(ColumnCounter);
        SetItem(Item2Flipped);
    }

    // Due to bugs/limitations with wxWidgets, certain stuff needs to be
    // physically taken from the list control as GetItem is finicky
    SetItemState(NextRow, Item1State, wxLIST_STATE_SELECTED
                 | wxLIST_STATE_FOCUSED);
    SetItemState(Row, Item2State, wxLIST_STATE_SELECTED
                 | wxLIST_STATE_FOCUSED);
    SetItemTextColour(NextRow, Item1Colour);
    SetItemTextColour(Row, Item2Colour);
}