/*************************************************** OnMouseMove - overloaded CUGCellType::OnMouseMove If the slider update state has been activated with during OnLClicked. Then this function tracks the position of the mouse and updates the cells value according to the mouses position along the slider (0-100 percent). As the value changes the slider is redrawn. **See CUGCellType::OnMouseMove for more details about this function ****************************************************/ BOOL CUGSliderType::OnMouseMove(int col,long row,POINT *point,UINT flags){ if((flags& MK_LBUTTON)== FALSE){ return FALSE; } if(m_updateSlider){ RECT rect; m_ctrl->GetCellRect(col,row,&rect); long mouseX = point->x - rect.left - 3; if(mouseX < 0) mouseX = 0; long width = rect.right - rect.left - 6; long percent = (mouseX*100)/width; if(percent < 0) percent = 0; if(percent > 100) percent = 100; CUGCell cell; m_ctrl->GetCellIndirect(col,row,&cell); if ( cell.GetReadOnly() == TRUE ) return FALSE; if(percent != (long)cell.GetNumber()) { cell.SetNumber(percent); m_ctrl->SetCell(col,row,&cell); m_ctrl->RedrawCell(col,row); OnCellTypeNotify(m_ID, col, row, UGCT_SLIDER_MOVED, percent); } return TRUE; } return FALSE; }
void CTWenUGCtrlEx::OnDClicked(int col,long row,RECT *rect,POINT *point,BOOL processed) { CUGCell cell; GetCell(col, row, &cell); if(!cell.GetReadOnly()) StartEdit(col, row, 0); }
/*************************************************** StartDropList This internal function is used to parse out the label string, which contains the items to show in the list. Also this function will show the list box in the proper location on the screen. Params: <none> Return: UG_ERROR - the list is already visible. UG_SUCCESS - everything went smoothly, the drop list was shown ***************************************************/ int CUGDropListType::StartDropList() { RECT rect; RECT clientRect; int dif,len,pos,startpos; CFont * font = NULL; LOGFONT lf; CFont * cfont; CStringList list; //lists of strings for the list are assembed here CString * items; //points to the string used to assemble the list //return false if it is already up if( m_listBox->m_HasFocus) return UG_ERROR; CUGCell cell; m_ctrl->GetCellIndirect(m_btnCol,m_btnRow,&cell); // make sure that the read only cells do not show droplist if ( cell.GetReadOnly() == TRUE ) return UG_SUCCESS; //get the current row and col m_btnCol = m_ctrl->GetCurrentCol(); m_btnRow = m_ctrl->GetCurrentRow(); //add the strings to the CStringList CString string; cell.GetLabelText(&string); items = &string; len = items->GetLength(); pos =0; startpos =0; while(pos <len){ if(items->GetAt(pos)== _T('\n')){ list.AddTail(items->Mid(startpos,pos-startpos)); startpos = pos+1; } pos++; } //notify the user of the list, so it can be modified if needed if ( OnCellTypeNotify(m_ID,m_btnCol,m_btnRow,UGCT_DROPLISTSTART,(LONG_PTR)&list) == FALSE ) // if FALSE was returned from OnCellTypeNotify call, than the developer does not // wish to show the drop list at the moment. return UG_ERROR; // set default font height lf.lfHeight = 12; //get the font if(cell.IsPropertySet(UGCELL_FONT_SET)) font = cell.GetFont(); else if(m_ctrl->m_GI->m_defFont != NULL) font = m_ctrl->m_GI->m_defFont; if(font == NULL) font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FONT)); if(font != NULL) { //find the height of the font cfont = font; cfont->GetLogFont(&lf); // lf.lfHeight if( lf.lfHeight < 0 ){ HDC hDC = CreateCompatibleDC(NULL); lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72); DeleteDC(hDC); } } //get the rectangle for the listbox m_ctrl->GetCellRect(m_btnCol,m_btnRow,&rect); rect.top = rect.bottom; rect.left+=10; rect.right+=10; len = (int)list.GetCount(); if(len >15) len = 15; rect.bottom += lf.lfHeight * len + 6; m_ctrl->m_CUGGrid->GetClientRect(&clientRect); if(rect.bottom > clientRect.bottom){ dif = rect.bottom - clientRect.bottom; rect.bottom -= dif; rect.top -= dif; if(rect.top <0) rect.top = 0; } if(rect.right > clientRect.right){ dif = rect.right - clientRect.right; rect.right -= dif; rect.left -= dif; if(rect.left <0) rect.left = 0; } //create the CListBox m_listBox->m_ctrl = m_ctrl; m_listBox->m_cellType = this; m_listBox->m_cellTypeId = m_ID; m_listBox->Create(WS_CHILD|WS_BORDER|WS_VSCROLL,rect,m_ctrl->m_CUGGrid,123); //set up the font if(font != NULL) m_listBox->SetFont(font); // v7.2 - update 03 - this works to eliminate blank lines that // can occur with odd sized fonts/number of items. Fix courtesy Gerbrand // .start int itHeight = m_listBox->GetItemHeight(0); if (len > 15) len = 15; rect.bottom = rect.top + len * itHeight + 6; if(rect.bottom > clientRect.bottom){ dif = rect.bottom - clientRect.bottom; rect.bottom -= dif; rect.top -= dif; if(rect.top <0) rect.top = 0; } // v7.2 - update 03 - Adjust the rect width to accomodate the largest string // Allen Shiels dif = GetMaxStringWidth(list) - (rect.right-rect.left); if (dif > 0) { if (len >= 15) // add a scroll bar width if max items in list dif += GetSystemMetrics(SM_CXVSCROLL); rect.right += dif; } if(rect.right > clientRect.right){ dif = rect.right - clientRect.right; rect.right -= dif; rect.left -= dif; if(rect.left <0) rect.left = 0; } // .end //resize the window again since a new font is being used m_listBox->MoveWindow(&rect,FALSE); //add the items to the list len = (int)list.GetCount(); POSITION position = list.GetHeadPosition(); pos =0; while(pos < len){ m_listBox->AddString(list.GetAt(position)); pos++; if(pos < len) list.GetNext(position); } //give the list box pointers to the cell m_listBox->m_col = &m_btnCol; m_listBox->m_row = &m_btnRow; m_listBox->ShowWindow(SW_SHOW); m_listBox->SetFocus(); m_btnDown = FALSE; m_ctrl->RedrawCell(m_btnCol,m_btnRow); return UG_SUCCESS; }