void gxEditCell::OnKillFocus (CWnd* pNewWnd) { CEdit::OnKillFocus(pNewWnd); SetListText(); DestroyWindow(); }
void ListPop::SetItem(int index) { for(int i = 0; i < pCurrentList->Count(); i++) { if(i == index) { SetListText((*pCurrentList)[i].text); selectedText = (*pCurrentList)[i].text; this->index = index; return; } } this->index = -1; selectedText.clear(); SetListText(""); }
void CEditCell::OnKillFocus (CWnd* pNewWnd) { CEdit::OnKillFocus(pNewWnd); SetListText(); if (pNewWnd == m_pListCtrl) { // Don't exit edit mode when other toplevel window gets the focus, // but save the text, just in case... Saves one click :-) DestroyWindow(); } }
int ListPop::SetItem(const gedString& text) { index = 0; gedString textCmp(text); if(pCurrentList->Count() && (*pCurrentList)[0].text[0] == '+') { //Has sub lists //Remove clone index int i = textCmp.find('.'); if(i != gedString::npos) { textCmp = textCmp.substr(0, i); } } for(int i = 0; i < pCurrentList->Count(); i++) { gedString itemText((*pCurrentList)[i].text); if(itemText[0] == '+') { //Remove expander itemText = itemText.substr(2); } if(textCmp == itemText) { SetListText(text); selectedText = text; return index; } index++; } index = -1; selectedText.clear(); SetListText(""); return -1; }
void CEditCell::OnChar (UINT nChar, UINT nRepCnt, UINT nFlags) { BOOL Shift = GetKeyState(VK_SHIFT) < 0; switch (nChar) { case VK_ESCAPE : { if (Shift) // Shift+Escape -> disable autocomplete m_DoSuggest = FALSE; else { m_bEscape = TRUE; GetParent()->SetFocus(); } return; } case VK_RETURN : { SetListText(); if (m_SubItem == 0) m_pListCtrl->EditSubItem (m_Item, 1); else m_pListCtrl->EditSubItem (m_Item + 1, 0); return; } case VK_TAB : { if (Shift) { if (m_SubItem > 0) m_pListCtrl->EditSubItem (m_Item, m_SubItem - 1); else { if (m_Item > 0) m_pListCtrl->EditSubItem (m_Item - 1, 2); } } else { if (m_SubItem == 0) m_pListCtrl->EditSubItem (m_Item, 1); else if (m_SubItem < 2) m_pListCtrl->EditSubItem (m_Item, m_SubItem + 1); else m_pListCtrl->EditSubItem (m_Item + 1, 0); } return; } } CEdit::OnChar (nChar, nRepCnt, nFlags); // Get text CString Text; GetWindowText(Text); // Make some suggestion if (m_DoSuggest && nChar != 8 && m_AutoComplete != NULL) { int iSelStart; int iSelEnd; GetSel(iSelStart, iSelEnd); CString sugg = GetSuggestion(Text); if (!sugg.IsEmpty()) { Text = sugg; SetWindowText(Text); SetSel(iSelStart, Text.GetLength()); } } // Resize edit control if needed CWindowDC DC (this); CFont *pFont = GetParent()->GetFont(); CFont *pFontDC = DC.SelectObject (pFont); CSize Size = DC.GetTextExtent (Text); DC.SelectObject (pFontDC); Size.cx += 5; // add some extra buffer // Get client rect CRect Rect, ParentRect; GetClientRect (&Rect); GetParent()->GetClientRect (&ParentRect); // Transform rect to parent coordinates ClientToScreen (&Rect); GetParent()->ScreenToClient (&Rect); // Check whether control needs to be resized and whether there is space to grow if (Size.cx > Rect.Width()) { if (Size.cx + Rect.left < ParentRect.right ) Rect.right = Rect.left + Size.cx; else Rect.right = ParentRect.right; MoveWindow (&Rect); } }
void gxEditCell::OnChar (UINT nChar, UINT nRepCnt, UINT nFlags) { BOOL Shift = GetKeyState (VK_SHIFT) < 0; switch (nChar) { case VK_ESCAPE : { if (nChar == VK_ESCAPE) bEscape = TRUE; GetParent()->SetFocus(); return; } case VK_RETURN : { SetListText(); pListCtrl->EditSubItem (Item + 1, 0); return; } case VK_TAB : { /* if (Shift) { if (SubItem > 0) pListCtrl->EditSubItem (Item, SubItem - 1); else { if (Item > 0) pListCtrl->EditSubItem (Item - 1, 2); } } else { if (SubItem < 2) pListCtrl->EditSubItem (Item, SubItem + 1); else pListCtrl->EditSubItem (Item + 1, 0); }*/ return; } } CEdit::OnChar (nChar, nRepCnt, nFlags); // Resize edit control if needed // Get text extent CString Text; GetWindowText (Text); CWindowDC DC (this); CFont *pFont = GetParent()->GetFont(); CFont *pFontDC = DC.SelectObject (pFont); CSize Size = DC.GetTextExtent (Text); DC.SelectObject (pFontDC); Size.cx += 5; // add some extra buffer // Get client rect CRect Rect, ParentRect; GetClientRect (&Rect); GetParent()->GetClientRect (&ParentRect); // Transform rect to parent coordinates ClientToScreen (&Rect); GetParent()->ScreenToClient (&Rect); // Check whether control needs to be resized and whether there is space to grow if (Size.cx > Rect.Width()) { if (Size.cx + Rect.left < ParentRect.right ) Rect.right = Rect.left + Size.cx; else Rect.right = ParentRect.right; MoveWindow (&Rect); } }
bool ListPop::OnList(ListPop *list, int index, gedString &text, int listId) { if(text == LIST_SEPARATOR) return true; int realFps = GameControl::Get()->getRealFrameRate(); if(realFps <= 0) realFps = 1; int interval = (int)(1000.0/realFps); selectedText.clear(); if(text[0] == '+') { //Expand clone names PopulateCloneList(&text.c_str()[2]); OnMouseButtonDown(GameControl::Get()->getMouseX(), GameControl::Get()->getMouseY(), 255); } else if(text == MORE_ITENS) { pCurrentStack->PushFront(firstListItem); ResetWork(); AddTextWork(LESS_ITENS); PopulateWorkList(true); OnMouseButtonDown(xMouse, yMouse, 255); } else if(text == LESS_ITENS) { firstListItem = pCurrentStack->Front(); pCurrentStack->PopFront(); ResetWork(); if(pCurrentStack->size()) AddTextWork(LESS_ITENS); PopulateWorkList(false); OnMouseButtonDown(xMouse, yMouse, 255); } else { if(!bButtonText) SetListText(text); selectedText = text; if(listId < 0) listId = listpopId; if(index < 0) { //Get index from text UseMainList(); for(int i = 0; i < pCurrentList->Count(); i++) { if(text == (*pCurrentList)[i].text) { index = i; break; } } if(index >= 0) this->index = index; } else { if(firstListItem > 0) index = firstListItem + index - 1; //Work index to all index UseMainList(); //Put after UseMainList() to get the //correct clone in the panel of getclone function this->index = index; } firstListItem = -1; getParent()->OnList(this, index, text, listId); } return true; }