void config_dialog::OnButDown() { // TODO: この位置にコントロール通知ハンドラ用のコードを追加してください int i; for(i=1;i<19;i++) if (lslpos[i] == 96 || rslpos[i] == 96) return; for(i=1;i<19;i++) { lslpos[i]++; rslpos[i]++; lsl[i]->SetPos(lslpos[i]); rsl[i]->SetPos(rslpos[i]); } not_applied = 1; m_but_apply.EnableWindow(TRUE); #if 0 for(paramlistelm *e = paramroot.elm;e != NULL;e = e->next) e->gain = e->gain - 1; sort_param(); #endif }
void config_dialog::set_paramlistelm_from_gui(int index) { int sel = m_list_param.GetCurSel(); paramlistelm *e = (paramlistelm *)m_list_param.GetItemDataPtr(index); e->left = m_ch_pleft2.GetCheck(); e->right = m_ch_pright2.GetCheck(); char str[64]; m_ed_pup.GetWindowText(str,63); e->upper = atof(str); m_ed_plow.GetWindowText(str,63); e->lower = atof(str); m_ed_gain.GetWindowText(str,63); e->gain = atof(str); m_list_param.DeleteString(index); m_list_param.InsertString(index,e->getString()); m_list_param.SetItemDataPtr(index,e); m_list_param.SetCurSel(sel); not_applied = 1; m_but_apply.EnableWindow(TRUE); sort_param(); }
void CChatListDlg::OnColumnclickChatSessions(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; int col = pNMListView->iSubItem; if (col == m_last_col) m_reverse = !m_reverse; else m_reverse = FALSE; m_last_col = col; t_chat_sort_param sort_param (m_pDoc, m_last_col, m_reverse); m_ctlChatList.SortItems (CompareFunc, (LPARAM) &sort_param); *pResult = 0; }
void CGenPropertyPage::OnColumnclickItemList(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; int col = pNMListView->iSubItem; if (col == m_last_col) m_reverse = !m_reverse; else m_reverse = FALSE; m_last_col = col; t_gen_sort_param sort_param (m_ObjectMap, m_last_col, m_reverse, m_CompareObjects); m_ctlList->SortItems (CompareFunc, (LPARAM) &sort_param); *pResult = 0; } // end of CGenPropertyPage::OnColumnclickItemList
void CChatListDlg::LoadList (void) { int nItem; // remember which chat IDs were previously selected m_SelectedList.RemoveAll (); // and focussed m_FocussedList.RemoveAll (); // do selected ones for (nItem = -1; (nItem = m_ctlChatList.GetNextItem(nItem, LVNI_SELECTED)) != -1;) m_SelectedList.AddTail (m_ctlChatList.GetItemData (nItem)); // do focussed ones for (nItem = -1; (nItem = m_ctlChatList.GetNextItem(nItem, LVNI_FOCUSED)) != -1;) m_FocussedList.AddTail (m_ctlChatList.GetItemData (nItem)); nItem = 0; m_ctlChatList.DeleteAllItems (); for (POSITION pos = m_pDoc->m_ChatList.GetHeadPosition(); pos; nItem++) { CChatSocket * p = m_pDoc->m_ChatList.GetNext (pos); // skip ones not yet connected if (p->m_bDeleteMe || p->m_iChatStatus != eChatConnected) continue; CString strFlags = MakeFlags (p); m_ctlChatList.InsertItem (nItem, p->m_strRemoteUserName); // eColumnChatName m_ctlChatList.SetItemText (nItem, eColumnGroup, p->m_strGroup); m_ctlChatList.SetItemText (nItem, eColumnFromIP, inet_ntoa (p->m_ServerAddr.sin_addr)); m_ctlChatList.SetItemText (nItem, eColumnCallIP, p->m_strAllegedAddress); m_ctlChatList.SetItemText (nItem, eColumnCallPort, CFormat ("%ld", p->m_iAllegedPort)); m_ctlChatList.SetItemText (nItem, eColumnFlags, strFlags); m_ctlChatList.SetItemData (nItem, p->m_iChatID); if (m_SelectedList.Find (p->m_iChatID)) m_ctlChatList.SetItemState (nItem, LVIS_SELECTED, LVIS_SELECTED); if (m_FocussedList.Find (p->m_iChatID)) m_ctlChatList.SetItemState (nItem, LVIS_FOCUSED, LVIS_FOCUSED); } // we have redone the list, redo the hash m_strListHash = MakeListHash (); t_chat_sort_param sort_param (m_pDoc, m_last_col, m_reverse); m_ctlChatList.SortItems (CompareFunc, (LPARAM) &sort_param); // set the 1st item to be selected - we do this here because sorting the // list means our first item is not necessarily the 1st item in the list if (m_SelectedList.IsEmpty ()) m_ctlChatList.SetItemState (0, LVIS_SELECTED, LVIS_SELECTED); if (m_FocussedList.IsEmpty ()) m_ctlChatList.SetItemState (0, LVIS_FOCUSED , LVIS_FOCUSED ); } // end of CChatListDlg::LoadList
void CGenPropertyPage::OnAddItem(CDialog & dlg) { // load dialog with default values InitDialog (&dlg); // display dialog, exit if cancelled if (dlg.DoModal () != IDOK) return; // create the object's lookup name (label converted to lower case, or generated) CObject * pItem; CString strObjectName; strObjectName = GetObjectName (&dlg); if (strObjectName.IsEmpty ()) strObjectName.Format ("*%s%s", // e.g. *trigger100 (LPCTSTR) m_strObjectType, (LPCTSTR) App.GetUniqueString ()); else strObjectName.MakeLower(); // if already there (presumably not possible with un-named objects), // then abort the add if (m_ObjectMap->Lookup (strObjectName, pItem)) { CString strMsg; strMsg = TFormat ("The %s named \"%s\" is already in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) GetObjectName (&dlg), (LPCTSTR) m_strObjectType); ::UMessageBox (strMsg); return; } // add new object to map m_ObjectMap->SetAt (strObjectName, pItem = MakeNewObject ()); // unload from dialog into object's properties UnloadDialog (&dlg, pItem); // They can no longer cancel the property sheet, the document has changed CancelToClose (); if (!CheckIfTemporary (pItem)) m_doc->SetModifiedFlag (TRUE); // create a CString for lookup purposes CString * pstrObjectName = new CString (strObjectName); // add this item to the list view add_item (pItem, pstrObjectName, 0, TRUE); SetInternalName (pItem, strObjectName); // set name so we can delete one-shot items // resort the list t_gen_sort_param sort_param (m_ObjectMap, m_last_col, m_reverse, m_CompareObjects); m_ctlList->SortItems (CompareFunc, (LPARAM) &sort_param); // redraw the list if (GetFilterFlag ()) LoadList (); // full reload because it may have changed filter requirements // get dispatch id from the script and put it into the item if (m_doc->m_ScriptEngine) { CString strMessage; SetDispatchID (pItem, m_doc->GetProcedureDispid (GetScriptName (pItem), m_strObjectType, GetLabel (pItem), strMessage)); if (!strMessage.IsEmpty ()) ::UMessageBox (strMessage, MB_ICONINFORMATION); } } // end of CGenPropertyPage::OnAddItem
void CGenPropertyPage::LoadList (void) { long iCount = 0; long iNotShown = 0; // for filtering CScriptEngine * m_ScriptEngine = NULL; // for the filtering checks bool bFiltering = GetFilterFlag (); if (bFiltering) { m_ScriptEngine = new CScriptEngine (m_doc, "Lua"); if (m_ScriptEngine->CreateScriptEngine ()) bFiltering = false; else { // compile filter script try { if (m_ScriptEngine->Parse (GetFilterScript (), "Script file")) bFiltering = false; } // end of try catch (CException * e) { e->ReportError (); e->Delete (); bFiltering = false; } } // not error creating engine } // end of filtering wanted lua_State * L = NULL; // if filtering, get the "filter" function on the stack if (bFiltering) { L = m_ScriptEngine->L; // make copy for convenience lua_settop(L, 0); // clear stack, just in case if (!GetNestedFunction (L, "filter", true)) bFiltering = false; } // remove all old items (we used the item data to key to the item) for (int nItem = 0; nItem < m_ctlList->GetItemCount (); nItem++) delete (CString *) m_ctlList->GetItemData (nItem); m_ctlList->DeleteAllItems (); CString strObjectName; CObject * pItem; // Item data for (POSITION pos = m_ObjectMap->GetStartPosition (); pos; ) { m_ObjectMap->GetNextAssoc (pos, strObjectName, pItem); bool bUse = true; // defaults to true if no filtering if (bFiltering) { lua_pushvalue(L, 1); // filter function lua_pushstring (L, (const char *) strObjectName); // key of the item GetFilterInfo (pItem, L); // table of related info if (lua_pcall (L, 2, 1, 0)) // call with 1 arg1 and 1 result { LuaError (L); bFiltering = false; } else { // use result if we get the exact type: boolean (true/false) if (lua_isboolean (L, -1)) { bUse = lua_toboolean (L, -1); if (!bUse) iNotShown++; // this one not shown } lua_pop (L, 1); // pop result } } // end of filtering wanted if (bUse) // add to list if passed filter { CString * pstrObjectName = new CString (strObjectName); add_item (pItem, pstrObjectName, 0, TRUE); iCount++; } } t_gen_sort_param sort_param (m_ObjectMap, m_last_col, m_reverse, m_CompareObjects); m_ctlList->SortItems (CompareFunc, (LPARAM) &sort_param); // set the 1st item to be selected - we do this here because sorting the // list means our first item is not necessarily the 1st item in the list if (!m_ObjectMap->IsEmpty ()) // provided we have any m_ctlList->SetItemState (0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); CString strSummary = TFormat ("%i item%s.", PLURAL (iCount)); if (iNotShown) strSummary += TFormat (" (%i item%s hidden by filter)", PLURAL (iNotShown)); m_ctlSummary->SetWindowText (strSummary); delete m_ScriptEngine; } // end of CGenPropertyPage::LoadList
void CGenPropertyPage::OnChangeItem(CDialog & dlg) { CString strMsg; // iterate through list in case we implement multiple selection one day for (int nItem = -1; (nItem = m_ctlList->GetNextItem(nItem, LVNI_SELECTED)) != -1;) { // get the lower-case name of this item's object CString * pstrObjectName = (CString *) m_ctlList->GetItemData (nItem); ASSERT (pstrObjectName != NULL); CObject * pItem; // check object is still there (it might have gone while we looked at the list box) if (!m_ObjectMap->Lookup (*pstrObjectName, pItem)) { m_ctlList->DeleteItem (nItem); // it's gone, so delete it from the list view m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list // in the case of one-shot timers, unnamed items might be removed from the list if (pstrObjectName->Left (1) == "*") strMsg = TFormat ("The %s you selected is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) m_strObjectType); else strMsg = TFormat ("The %s named \"%s\" is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName, (LPCTSTR) m_strObjectType); ::UMessageBox (strMsg); delete pstrObjectName; // and get rid of its name string continue; } ASSERT_VALID (pItem); ASSERT( pItem->IsKindOf( RUNTIME_CLASS( CObject ) ) ); // load dialog with values from the found item LoadDialog (&dlg, pItem); // put up the dialog, give up if they cancel if (dlg.DoModal () != IDOK) continue; // lookup this object, to make sure it still exists if (!m_ObjectMap->Lookup (*pstrObjectName, pItem)) { m_ctlList->DeleteItem (nItem); // it's gone, so delete it from the list view m_ctlList->RedrawItems (0, m_ctlList->GetItemCount () - 1); // redraw the list // in the case of one-shot timers, unnamed items might be removed from the list if (pstrObjectName->Left (1) == "*") strMsg = TFormat ("The %s you selected is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) m_strObjectType); else strMsg = TFormat ("The %s named \"%s\" is no longer in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName, (LPCTSTR) m_strObjectType); delete pstrObjectName; // and get rid of its name string ::UMessageBox (strMsg); continue; } ASSERT_VALID (pItem); ASSERT( pItem->IsKindOf( RUNTIME_CLASS( CObject ) ) ); if (CheckIfIncluded (pItem)) { strMsg = TFormat ("The %s named \"%s\" has been included from an include file. You cannot modify it here.", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName); ::UMessageBox (strMsg); return; // can't modify included items } // check object still has the same modification number // (it might have been modified while we looked at the list box) if (GetModificationNumber (pItem) != m_nUpdateNumber) { strMsg = TFormat ("The %s named \"%s\" has already been modified by a script subroutine", (LPCTSTR) m_strObjectType, (LPCTSTR) *pstrObjectName); ::UMessageBox (strMsg); continue; } // check for name change CString strObjectName = GetObjectName (&dlg); if (strObjectName.IsEmpty ()) strObjectName.Format ("*%s%s", (LPCTSTR) m_strObjectType, (LPCTSTR) App.GetUniqueString ()); else strObjectName.MakeLower (); if (strObjectName != *pstrObjectName) // has name changed? { // here if label has changed CObject * new_pItem; if (m_ObjectMap->Lookup (strObjectName, new_pItem)) { strMsg = TFormat ("The %s named \"%s\" already exists in the %s list", (LPCTSTR) m_strObjectType, (LPCTSTR) strObjectName, (LPCTSTR) m_strObjectType); ::UMessageBox (strMsg); continue; } // remove old entry and re-add under new name m_ObjectMap->RemoveKey (*pstrObjectName); // remove old entry m_ObjectMap->SetAt (strObjectName, pItem); // insert under new name // delete old name in the list delete pstrObjectName; // create a new CString for lookup purposes pstrObjectName = new CString (strObjectName); // record item's new name as the list object data m_ctlList->SetItemData(nItem, (DWORD) pstrObjectName); } // end of label changing // see if the user changed anything, anyway if (CheckIfChanged (&dlg, pItem)) { // unload from dialog into object's properties UnloadDialog (&dlg, pItem); // They can no longer cancel the property sheet, the document has changed CancelToClose (); if (!CheckIfTemporary (pItem)) m_doc->SetModifiedFlag (TRUE); // re-setup list with amended details int nNewItem = add_item (pItem, pstrObjectName, nItem, FALSE); m_ctlList->RedrawItems (nNewItem, nNewItem); } // end of item changing // Get dispatch id from the script and put it into the item. // We do this even if nothing has changed, so that we can force re-evaluation // of the dispatch ID, by just getting the item and pressing OK. if (m_doc->m_ScriptEngine) { CString strMessage; SetDispatchID (pItem, m_doc->GetProcedureDispid (GetScriptName (pItem), m_strObjectType, GetLabel (pItem), strMessage)); if (!strMessage.IsEmpty ()) ::UMessageBox (strMessage, MB_ICONINFORMATION); } } // end of dealing with each selected item // redraw the list if (GetFilterFlag ()) LoadList (); // full reload because it may have changed filter requirements // resort the list t_gen_sort_param sort_param (m_ObjectMap, m_last_col, m_reverse, m_CompareObjects); m_ctlList->SortItems (CompareFunc, (LPARAM) &sort_param); } // end of CGenPropertyPage::OnChangeItem