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; }
BOOL CashListView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { int scroll = zDelta / WHEEL_DELTA; SetTopItem(topItem_ - scroll); return CWnd::OnMouseWheel(nFlags, zDelta, pt); }
// Create the document bool ctConfigToolDoc::OnCreate(const wxString& path, long flags) { GetCommandProcessor()->SetEditMenu(wxGetApp().GetMainFrame()->GetEditMenu()); GetCommandProcessor()->Initialize(); GetCommandProcessor()->ClearCommands(); // wxGetApp().m_currentDoc = this; if (flags & wxDOC_NEW) { ctConfigItem* rootItem = new ctConfigItem(NULL, ctTypeGroup, _T("Configuration")); //rootItem->InitProperties(); rootItem->GetProperties().AddProperty( new ctProperty( wxT("The item description."), wxVariant(wxT(""), wxT("description")), wxT("multiline"))); rootItem->SetPropertyString(_T("description"), _T("<B>This is the top-level configuration item.</B>")); SetTopItem(rootItem); Modify(false); SetDocumentSaved(false); wxString rootName(wxT("untitled")); wxStripExtension(rootName); SetFilename(wxGetApp().GetSettings().GenerateFilename(rootName)); } // Creates the view, so do any view updating after this bool success = wxDocument::OnCreate(path, flags); if (success) { if (flags & wxDOC_NEW) { wxBusyCursor wait; ctConfigToolHint hint(NULL, ctInitialUpdate); UpdateAllViews (NULL, & hint); SetFilename(GetFilename(), true); } } return success; }
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; }
void CashListView::EnsureItemVisiable(int index) { int newTopItem = topItem_; CRect clientRect; GetClientRect(&clientRect); if (index < topItem_) { newTopItem = __max(index, 0); } else { int count = 1 + (index - topItem_) + 1; int dist = count * itemHeight_ - clientRect.Height(); if (dist > 0) { newTopItem = topItem_ + (dist + itemHeight_ - 1) / itemHeight_; } } SetTopItem(newTopItem); }
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; }
bool ctConfigToolDoc::DoOpen(wxSimpleHtmlTag* tag, ctConfigItem* parent) { ctConfigItem* newItem = NULL; if (tag->NameIs(wxT("setting"))) { wxSimpleHtmlAttribute* attr = tag->FindAttribute(wxT("type")); if (attr) { ctConfigType type = ctTypeUnknown; wxString typeStr(attr->GetValue()); if (typeStr == wxT("group")) type = ctTypeGroup; else if (typeStr == wxT("option-group") || typeStr == wxT("check-group")) type = ctTypeCheckGroup; else if (typeStr == wxT("radio-group")) type = ctTypeRadioGroup; else if (typeStr == wxT("bool-check")) type = ctTypeBoolCheck; else if (typeStr == wxT("bool-radio")) type = ctTypeBoolRadio; else if (typeStr == wxT("string")) type = ctTypeString; else if (typeStr == wxT("integer")) type = ctTypeInteger; else { wxLogError(wxT("Unknown type %s"), (const wxChar*) typeStr); } if (type != ctTypeUnknown) { newItem = new ctConfigItem(parent, type, wxT("")); newItem->InitProperties(); if (!parent) SetTopItem(newItem); } } } wxSimpleHtmlTag* childTag = tag->GetChildren(); while (childTag) { if (childTag->GetType() == wxSimpleHtmlTag_Open) { if (childTag->GetName() == wxT("setting")) { DoOpen(childTag, newItem); } else if (childTag->GetName() == wxT("name")) { if (newItem) { wxString name(childTag->GetNext()->GetTagText()); newItem->SetName(name); } } else if (childTag->GetName() == wxT("active")) { if (newItem) newItem->SetActive(GetHtmlBoolValue(childTag->GetNext()->GetTagText())); } else if (childTag->GetName() == wxT("enabled")) { if (newItem) newItem->Enable(GetHtmlBoolValue(childTag->GetNext()->GetTagText())); } else { if (newItem) { ctProperty* prop = newItem->GetProperties().FindProperty(childTag->GetName()); if (!prop) { // A custom property, else an obsolete // property that we should ignore. wxString isCustom; if (childTag->GetAttributeValue(isCustom, wxT("custom")) && isCustom == wxT("true")) { prop = new ctProperty; wxString name(childTag->GetName()); wxString type(wxT("string")); wxString choices; wxString editorType(wxT("string")); wxString description(wxT("")); childTag->GetAttributeValue(type, wxT("type")); childTag->GetAttributeValue(type, wxT("editor-type")); childTag->GetAttributeValue(type, wxT("choices")); childTag->GetAttributeValue(description, wxT("description")); if (type == wxT("bool")) prop->GetVariant() = wxVariant(false, name); else if (type == wxT("double")) prop->GetVariant() = wxVariant((double) 0.0, name); else if (type == wxT("long")) prop->GetVariant() = wxVariant((long) 0, name); else prop->GetVariant() = wxVariant(wxT(""), name); prop->SetDescription(description); prop->SetCustom(true); prop->SetEditorType(editorType); if (!choices.IsEmpty()) { wxArrayString arr; ctConfigItem::StringToArray(choices, arr); prop->SetChoices(arr); } newItem->GetProperties().AddProperty(prop); } } if (prop) { if (prop->GetVariant().GetType() == wxT("string")) prop->GetVariant() = childTag->GetNext()->GetTagText(); else if (prop->GetVariant().GetType() == wxT("long")) prop->GetVariant() = (long) GetHtmlIntegerValue(childTag->GetNext()->GetTagText()); else if (prop->GetVariant().GetType() == wxT("bool")) prop->GetVariant() = GetHtmlBoolValue(childTag->GetNext()->GetTagText()); else if (prop->GetVariant().GetType() == wxT("double")) prop->GetVariant() = (double) GetHtmlDoubleValue(childTag->GetNext()->GetTagText()); } } } } childTag = childTag->GetNext(); } return true; }