void bydpListView::NewData(int howmany, char **data, int current) { // printf("in newdata w/ %i,%i,%s\n",current,howmany,data[1]); words = data; wordCount = howmany; valid = true; NewSize(); // updates visible... ListRefresh(); ListRefresh(current); // forced refresh, required this->Select(current-topIndex); }
void bydpListView::KeyDown(const char *bytes, int32 numBytes) { if (numBytes == 1) { switch (bytes[0]) { case B_HOME: ListRefresh(0); this->Select(0); myHandler->Looper()->PostMessage(new BMessage(MSG_LISTUP)); break; case B_END: ListRefresh(wordCount-visible); this->Select(visible-1); myHandler->Looper()->PostMessage(new BMessage(MSG_LISTUP)); break; case B_PAGE_UP: topIndex -= visible; ListRefresh(); myHandler->Looper()->PostMessage(new BMessage(MSG_LISTUP)); this->Select(0); break; case B_PAGE_DOWN: topIndex += visible; ListRefresh(); myHandler->Looper()->PostMessage(new BMessage(MSG_LISTUP)); this->Select(visible-1); break; case B_UP_ARROW: // printf("listupmsg\n"); if (this->CurrentSelection(0) == 0) { myHandler->Looper()->PostMessage(new BMessage(MSG_LISTUP)); List1Up(); } else BListView::KeyDown(bytes,numBytes); break; case B_DOWN_ARROW: // printf("listdownmsg\n"); if (this->CurrentSelection(0)+1 == this->CountItems()) { myHandler->Looper()->PostMessage(new BMessage(MSG_LISTDOWN)); List1Down(); } else BListView::KeyDown(bytes,numBytes); break; default: BListView::KeyDown(bytes,numBytes); } } else { BListView::KeyDown(bytes,numBytes); } myBar->BlockSignals(true); myBar->SetValue(topIndex+this->CurrentSelection(0)); myBar->BlockSignals(false); }
void bydpListView::NewSize(void) { float dictSize; float itemSize; font_height myHeight; this->GetFontHeight(&myHeight); dictSize = this->Bounds().Height(); itemSize = myHeight.leading+myHeight.ascent+myHeight.descent; visible = (int)(dictSize/itemSize-2); if (visible<1) visible = 1; if (visible>wordCount) visible=wordCount; if (valid) { if (visible<wordCount) myBar->SetRange(0.0,(float)wordCount-1); else myBar->SetRange(0.0, 0.0); } // printf("in newsize with %i\n",visible); int i; void *anItem; for (i=0; (anItem=this->ItemAt(i)); i++) delete anItem; this->MakeEmpty(); for (i=0; i<visible; i++) this->AddItem(new BStringItem("")); ListRefresh(); }
//插入 void CLaserAdjust::OnLaserinster() { int istat = m_ListLaserAdjust.GetSelectionMark();//獲取選擇的項 m_ListLaserAdjust.InsertItem(istat, NULL); ((CCommandTestDlg*)pMain)->a.LaserAdjust.insert(((CCommandTestDlg*)pMain)->a.LaserAdjust.begin() + istat, { 0 }); ListRefresh(); }
BOOL CLaserAdjust::OnInitDialog() { CDialogEx::OnInitDialog(); m_ListLaserAdjust.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); m_ListLaserAdjust.InsertColumn(0, _T("順序"), LVCFMT_CENTER, 36, -1); m_ListLaserAdjust.InsertColumn(1, _T("雷射值"), LVCFMT_LEFT, 100, -1); ListRefresh(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX 屬性頁應傳回 FALSE }
void bydpListView::ListScrolled(int value) { // printf("got value:%i\n",value); ListRefresh(value,false); this->Select(value-topIndex); }
//新增 void CLaserAdjust::OnOK() { ((CCommandTestDlg*)pMain)->a.LaserAdjust.push_back({0}); ListRefresh(); // CDialogEx::OnOK(); }
//刪除 void CLaserAdjust::OnLaserdelete() { int istat = m_ListLaserAdjust.GetSelectionMark();//獲取選擇的項 ((CCommandTestDlg*)pMain)->a.LaserAdjust.erase(((CCommandTestDlg*)pMain)->a.LaserAdjust.begin() + istat); ListRefresh(); }