void WaveExplorerUi::UpdateItemWave() { ClearItemsData(); if (style_changed_) { DeleteDataSet(); } int width = SetItemWidth(); QPixmap pixmap(width, PIXMPA_HEIGHT); MDataBase *db = MDataBase::GetInstance(); QList<int> sid_list = db->RawWaveInfoIdList(); for (int i = 0; i < sid_list.count(); i++) { int sid = sid_list.at(i); MISEIS_F_CONTINUE(GetPixmap(sid, i, &pixmap)); QListWidgetItem *item = new QListWidgetItem; item->setIcon(QIcon(pixmap)); item->setFlags(Qt::ItemIsEnabled); this->addItem(item); wave_list_.append(sid); } style_changed_ = false; }
// 删除指定tab页 void CDuiTabCtrl::DeleteItem(int nItem) { if((nItem < 0) || (nItem >= (int)m_vecItemInfo.size())) { return; } int nIndex = 0; vector<TabItemInfo>::iterator it; for(it=m_vecItemInfo.begin();it!=m_vecItemInfo.end();++it) { if(nIndex == nItem) { TabItemInfo &itemInfo = *it; if(itemInfo.pControl != NULL) { RemoveControl(itemInfo.pControl); } m_vecItemInfo.erase(it); break; } nIndex++; } // 调整tab页签的宽度 SetItemWidth(m_nTabItemMaxWidth, m_nTabItemMinWidth, FALSE); // 重新计算每个tab页的位置,并刷新界面 RefreshItems(); }
void CEnHeaderCtrl::ShowItem(int nItem, BOOL bShow) { if (ModifyItemFlags(nItem, EHCF_HIDDEN, !bShow)) { // resize as necessary if (bShow) { ASSERT(nItem < m_aItemWidths.GetSize()); int nWidth = m_aItemWidths[nItem]; SetItemWidth(nItem, nWidth); } else // hide { m_aItemWidths.SetAtGrow(nItem, (WORD)GetItemWidth(nItem)); SetItemWidth(nItem, 0); } } }
void CDuiTabCtrl::SetControlRect(CRect rc) { __super::SetControlRect(rc); // 调整tab页签的宽度 SetItemWidth(m_nTabItemMaxWidth, m_nTabItemMinWidth, FALSE); // 重新计算所有Tab页的位置 RefreshItems(); }
void CHeaderCtrlExt::EndDragDivider(BOOL bSubmit) { if(! m_bDragFullWindow)DrawDragDivider(); if(bSubmit) { if(! m_bDragFullWindow) { int dx = m_ptDragEnd.x - m_ptDragStart.x; int cxy = max(0, m_nItemWidth + dx); SetItemWidth(m_nDraggingItem, cxy); } } else { // cancel and restore the original width if(m_bDragFullWindow)SetItemWidth(m_nDraggingItem, m_nItemWidth); } m_nDraggingItem = -1; ReleaseCapture(); }
BOOL CEnHeaderCtrl::SetItemWidths(const CIntArray& aWidths) { int nItem = GetItemCount(); ASSERT(nItem == aWidths.GetSize()); if (nItem != aWidths.GetSize()) return FALSE; while (nItem--) { if (!SetItemWidth(nItem, aWidths[nItem], FALSE)) return FALSE; } RecalcItemTooltipRects(); return TRUE; }
void CUIListWnd::InitListWnd(Fvector2 pos, Fvector2 size, float item_height) { inherited::SetWndPos(pos); inherited::SetWndSize(size); //добавить полосу прокрутки m_ScrollBar = xr_new<CUIScrollBar>(); m_ScrollBar->SetAutoDelete(true); AttachChild(m_ScrollBar); if (!!m_scrollbar_profile) m_ScrollBar->InitScrollBar(Fvector2().set(size.x,0.0f), size.y, false, *m_scrollbar_profile); else m_ScrollBar->InitScrollBar(Fvector2().set(size.x,0.0f), size.y, false); m_ScrollBar->SetWndPos( Fvector2().set(m_ScrollBar->GetWndPos().x - m_ScrollBar->GetWidth(), m_ScrollBar->GetWndPos().y)); SetItemWidth(size.x - m_ScrollBar->GetWidth()); m_iFirstShownIndex = 0; SetItemHeight(item_height); m_iRowNum = iFloor(size.y/m_iItemHeight); m_ScrollBar->SetRange(0,0); m_ScrollBar->SetPageSize(0); m_ScrollBar->SetScrollPos(s16(m_iFirstShownIndex)); m_ScrollBar->Show(false); m_ScrollBar->Enable(false); /* m_StaticActiveBackground.Init(ACTIVE_BACKGROUND,"hud\\default", 0,0,alNone); m_StaticActiveBackground.SetTile(iFloor(m_iItemWidth/ACTIVE_BACKGROUND_WIDTH), iFloor(m_iItemHeight/ACTIVE_BACKGROUND_HEIGHT), fmod(m_iItemWidth,float(ACTIVE_BACKGROUND_WIDTH)), fmod(m_iItemHeight,float(ACTIVE_BACKGROUND_HEIGHT))); */ UpdateList(); }
void CUIListWnd::Init(float x, float y, float width, float height, float item_height) { CUIWindow::Init(x, y, width, height); //добавить полосу прокрутки m_ScrollBar = xr_new<CUIScrollBar>(); m_ScrollBar->SetAutoDelete(true); AttachChild(m_ScrollBar); if (!!m_scrollbar_profile) m_ScrollBar->Init(width,0,height, false, *m_scrollbar_profile); else m_ScrollBar->Init(width,0,height, false); m_ScrollBar->SetWndPos(m_ScrollBar->GetWndPos().x - m_ScrollBar->GetWidth(), m_ScrollBar->GetWndPos().y); SetItemWidth(width - m_ScrollBar->GetWidth()); m_iFirstShownIndex = 0; SetItemHeight(item_height); m_iRowNum = iFloor(height/m_iItemHeight); m_ScrollBar->SetRange(0,0); m_ScrollBar->SetPageSize(s16(0)); m_ScrollBar->SetScrollPos(s16(m_iFirstShownIndex)); m_ScrollBar->Show(false); m_ScrollBar->Enable(false); /* m_StaticActiveBackground.Init(ACTIVE_BACKGROUND,"hud\\default", 0,0,alNone); m_StaticActiveBackground.SetTile(iFloor(m_iItemWidth/ACTIVE_BACKGROUND_WIDTH), iFloor(m_iItemHeight/ACTIVE_BACKGROUND_HEIGHT), fmod(m_iItemWidth,float(ACTIVE_BACKGROUND_WIDTH)), fmod(m_iItemHeight,float(ACTIVE_BACKGROUND_HEIGHT))); */ UpdateList(); }
void CHeaderCtrlExt::SetVisible(int nIndex, BOOL bVisible) { CItemData* pData = (CItemData*)GetItemData(nIndex); if(! pData)return; if(pData->m_bVisible != bVisible) { pData->m_bVisible = bVisible; // get total items int nCount = GetItemCount(); // get current item's order int nOrder = IndexToOrder(nIndex); int* piCols = new int[nCount]; ASSERT(piCols); GetOrderArray(piCols, nCount); if(bVisible) { // restore item width ResetItemWidth(nIndex); // move the item to the original position int nTarget; int nVisible = GetVisibleItemCount(); if(nIndex > nVisible - 1)nTarget = nVisible - 1; else nTarget = nIndex; ASSERT(nTarget <= nOrder); for(int i = nOrder;i > nTarget;--i)piCols[i] = piCols[i - 1]; piCols[nTarget] = nIndex; } else { // hide item SetItemWidth(nIndex, 0); } SetOrderArray(nCount, piCols); delete []piCols; } }
void CHeaderCtrlExt::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(m_nDraggingItem >= 0) { int dx = point.x - m_ptDragStart.x; int cxy = max(0, m_nItemWidth + dx); if(m_bDragFullWindow)SetItemWidth(m_nDraggingItem, cxy); else { DrawDragDivider(); m_ptDragMove = point; DrawDragDivider(); } return; } CHeaderCtrl::OnMouseMove(nFlags, point); }
// 删除指定tab页(按照名字) void CDuiTabCtrl::DeleteItem(CString strTabName) { vector<TabItemInfo>::iterator it; for(it=m_vecItemInfo.begin();it!=m_vecItemInfo.end();++it) { TabItemInfo &itemInfo = *it; if(itemInfo.strName == strTabName) { if(itemInfo.pControl != NULL) { RemoveControl(itemInfo.pControl); } m_vecItemInfo.erase(it); break; } } // 调整tab页签的宽度 SetItemWidth(m_nTabItemMaxWidth, m_nTabItemMinWidth, FALSE); // 重新计算每个tab页的位置,并刷新界面 RefreshItems(); }
BOOL CEnHeaderCtrl::SetItemWidth(int nItem, int nWidth) { return SetItemWidth(nItem, nWidth, TRUE); }
BOOL CDuiTabCtrl::InsertItem(int nItem, TabItemInfo &itemInfo) { if(m_vecItemInfo.size() > 0) { CRect rc; m_vecRcSeperator.push_back(rc); } if(nItem <= -1 || nItem >= (int)m_vecItemInfo.size()) { m_vecItemInfo.push_back(itemInfo); } else { m_vecItemInfo.insert(m_vecItemInfo.begin() + nItem, itemInfo); } int nXPos = m_rc.left + m_nTabLeftPading; int nYPos = m_rc.top; int nXTabBtnPos = m_nTabLeftPading; for(size_t i = 0; i < (int)m_vecItemInfo.size(); i++) { TabItemInfo &itemInfoTemp = m_vecItemInfo.at(i); int nItemWidth = itemInfoTemp.rc.Width(); int nItemHeight = itemInfoTemp.sizeImage.cy; if(m_nTabItemWidth == 0) { // 如果tabctrl没有设置每个tab页的宽度,则以第一个tab页的图片宽度为准 m_nTabItemWidth = nItemWidth; } if(m_nTabCtrlHeight == 0) { // 如果tabctrl没有设置高度,则以第一个tab页的图片高度为准 m_nTabCtrlHeight = nItemHeight; } // 设置tab页签的位置 itemInfoTemp.rc.SetRect(nXPos, nYPos, nXPos + m_nTabItemWidth, nYPos + m_nTabCtrlHeight); // 设置Tab页签按钮的位置 if(m_pImageTabBtn != NULL) { int nLeft = nXTabBtnPos; int nTop = 3; // 计算Tab页签按钮的显示位置 if(m_posTabBtn.nCount >= 2) { // 使用设置的Tab页签按钮位置 int nTabBtnX = PositionItem2Value(m_posTabBtn.Left, 0, m_nTabItemWidth); int nTabBtnY = PositionItem2Value(m_posTabBtn.Top, 0, m_nTabCtrlHeight); nLeft += nTabBtnX; nTop += nTabBtnY; }else { // 如果没有设置位置信息,则设置默认的位置为靠tab页签右上角 nLeft += (m_nTabItemWidth - m_sizeTabBtn.cx - 3); nTop += 3; } itemInfoTemp.rcButton.SetRect(nLeft, nTop, nLeft + m_sizeTabBtn.cx, nTop + m_sizeTabBtn.cy); } nXPos += m_nTabItemWidth; nXTabBtnPos += m_nTabItemWidth; if(i < m_vecItemInfo.size() - 1 && m_pImageSeperator != NULL) { CRect &rc = m_vecRcSeperator.at(i); rc.SetRect(nXPos, nYPos, nXPos + m_sizeSeperator.cx, nYPos + m_sizeSeperator.cy); nXPos += m_sizeSeperator.cx; nXTabBtnPos += m_sizeSeperator.cx; } itemInfoTemp.buttonState = enBSNormal; /* if(itemInfoTemp.pControl != NULL) { CRect rc = itemInfoTemp.pControl->GetRect(); rc.top += itemInfoTemp.sizeImage.cy; itemInfoTemp.pControl->SetRect(rc); //itemInfoTemp.pControl->UpdateControl(); }*/ } // 调整tab页签的宽度 SetItemWidth(m_nTabItemMaxWidth, m_nTabItemMinWidth); UpdateControl(true); return true; }
void CHeaderCtrlExt::ResetItemWidth(int nIndex) { CItemData* pData = (CItemData*)GetItemData(nIndex); if(pData)SetItemWidth(nIndex, pData->m_nWidth); }