void FixMenus() { SetMItemEnable(GetMenuHandle(kFileMenuID), 2, false); SetMItemEnableRange(GetMenuHandle(kEditMenuID), 1,6, false); if(cart_data!=0) { SetMItemEnableRange(GetMenuHandle(kNESMenuID), 1,7, true); SetMItemEnableRange(GetMenuHandle(kSearchMenuID), 1,7, true); SetMItemEnable(GetMenuHandle(kEditMenuID), 8, true); SetMItemEnable(GetMenuHandle(kNESMenuID), 1, !gRunning); SetMItemEnable(GetMenuHandle(kNESMenuID), 2, gRunning); #ifdef GB_DEBUG SetMItemEnableRange(GetMenuHandle(kExtraMenuID), 1,10, true); CheckItem(GetMenuHandle(kExtraMenuID),1,(patWind!=0L)); CheckItem(GetMenuHandle(kExtraMenuID),2,(namWind!=0L)); CheckItem(GetMenuHandle(kExtraMenuID),3,(palWind!=0L)); #endif CheckItem(GetMenuHandle(kSearchMenuID),5,(srchWind!=0L)); CheckItem(GetMenuHandle(kSearchMenuID),6,(wpWind!=0L)); } else { SetMItemEnableRange(GetMenuHandle(kNESMenuID), 1,7, false); SetMItemEnableRange(GetMenuHandle(kSearchMenuID), 1,7, false); SetMItemEnable(GetMenuHandle(kEditMenuID), 8, false); #ifdef GB_DEBUG SetMItemEnableRange(GetMenuHandle(kExtraMenuID), 1,10, false); #endif } }
void CTablemapCompletenessChecker::CheckMainPot() { if (p_tablemap->ItemExists("c0pot0chip00")) { CheckItem("c0pot0chip01"); CheckItem("c0pot0chip10"); } else { CheckItem("c0pot0"); } }
void CTablemapCompletenessChecker::CheckBetsOrChips() { bool tm_uses_stacks = p_tablemap->ItemExists("p0chip00"); int nchairs = p_tablemap->nchairs(); for (int i=0; i<nchairs; ++i) { if (tm_uses_stacks) { CheckItem("p", i, "chip00"); CheckItem("p", i, "chip01"); CheckItem("p", i, "chip10"); } else { CheckItem("p", i, "bet"); } } }
void CTablemapCompletenessChecker::CheckCardFaces(CString prefix, int infix, CString postfix) { CString name; name.Format("%s%d%s", prefix, infix, postfix); CString rank_name = name + "rank"; if (p_tablemap->ItemExists(rank_name)) { // If a rank exists then the suit also needs to get scraped CString suit_name = name + "suit"; CheckItem(suit_name); } else { // Default: cardface must be there CheckItem(name); } }
void CListCtrlEx::OnLButtonDown(UINT nFlags, CPoint point) { UINT uFlags = 0; int nHitItem = HitTest(point, &uFlags); // we need additional checking in owner-draw mode // because we only get LVHT_ONITEM BOOL bHit = FALSE; if (uFlags == LVHT_ONITEM && (GetStyle() & LVS_OWNERDRAWFIXED)) { CRect rect; GetItemRect(nHitItem, rect, LVIR_BOUNDS); LV_COLUMN lvc; lvc.mask = LVCF_FMT | LVCF_WIDTH; GetColumn(0, &lvc); // check if hit was on a state icon if (point.x >= (rect.left+lvc.cx)) bHit = TRUE; } else if (uFlags & LVHT_ONITEMSTATEICON) bHit = TRUE; if (bHit) CheckItem(nHitItem); else { if (m_pEdit) EndEditItem(); CListCtrl::OnLButtonDown(nFlags, point); } }
void modify_menu_item( short menu, short item, boolean status, short check) { MenuHandle menu_handle; menu_handle= GetMHandle(menu); assert(menu_handle); if (menu_handle) { if (status) { EnableItem(menu_handle, item); } else { DisableItem(menu_handle, item); } if (check!=NONE) { CheckItem(menu_handle, item, check); } } return; }
void JXFontCharSetMenu::Receive ( JBroadcaster* sender, const Message& message ) { if ((sender == itsFontNameMenu && message.Is(JXFontNameMenu::kNameChanged)) || (sender == itsFontSizeMenu && message.Is(JXFontSizeMenu::kSizeChanged))) { itsBroadcastChangeFlag = kJFalse; const JString charSet = GetCharSet(); const JString fontName = itsFontNameMenu->GetFontName(); BuildMenu(fontName, itsFontSizeMenu->GetFontSize()); SetCharSet(charSet); itsBroadcastChangeFlag = kJTrue; } else if (sender == this && message.Is(JXMenu::kNeedsUpdate)) { itsBroadcastChangeFlag = kJFalse; Broadcast(CharSetNeedsUpdate()); CheckItem(itsCurrIndex); itsBroadcastChangeFlag = kJTrue; } else if (sender == this && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast(const JXMenu::ItemSelected*, &message); assert( selection != NULL ); ChooseCharSet(selection->GetIndex()); } else {
void CRowListView::OnLButtonDown(UINT nFlags, CPoint point) { UINT uFlags = 0; int nHitItem = GetListCtrl().HitTest(point, &uFlags); // we need additional checking in owner-draw mode // because we only get LVHT_ONITEM BOOL bHit = FALSE; if (uFlags == LVHT_ONITEM && (GetStyle() & LVS_OWNERDRAWFIXED)) { CRect rect; GetListCtrl().GetItemRect(nHitItem, rect, LVIR_ICON); // check if hit was on a state icon if (m_bStateIcons && point.x < rect.left) bHit = TRUE; } else if (uFlags & LVHT_ONITEMSTATEICON) bHit = TRUE; if (bHit) CheckItem(nHitItem); else CListViewEx::OnLButtonDown(nFlags, point); }
bool GUICheckMenuItem( gui_window *wnd, gui_ctl_id id, bool check, bool floating ) { HMENU hmenu, popup, parent; gui_ctl_idx position; hint_type type; if( floating ) { type = FLOAT_HINT; } else { type = MENU_HINT; } hmenu = GetOrMakeHMENU( wnd, floating, NULL ); if( hmenu == NULLHANDLE ) { return( false ); } popup = GetPopupHMENU( wnd, hmenu, id, &parent, &position, MENU_HINT ); if( popup != NULLHANDLE ) { CheckPopup( parent, position, check ); } else { CheckItem( hmenu, id, check ); } if( hmenu == parent ) { GUIDrawMenuBar( wnd ); } return( true ); }
void CComplexSymbolLayerCtrl::OnNMClick(NMHDR *pNMHDR, LRESULT *pResult) { UINT uFlags = 0; LPNMITEMACTIVATE phdr = reinterpret_cast< LPNMITEMACTIVATE >( pNMHDR ); POINT point; bool bSet; point.x=phdr->ptAction.x; point.y=phdr->ptAction.y; if( phdr->iItem!=-1 ) { ResetItem( m_nSelect ); if( m_nSelect==phdr->iItem ) bSet = false; else bSet = true; m_nSelect = phdr->iItem; CRect rect; this->GetItemRect( m_nSelect , rect , LVIR_ICON ); if ( point.x < rect.left) { CheckItem( phdr->iItem ); m_IComplexSymbolLayerCtrl->SetCopySymbol(); } else { CheckItemEx( phdr->iItem ); } if(bSet) m_IComplexSymbolLayerCtrl->SetPropList( phdr->iItem ); ::SendMessage(GetParent()->m_hWnd , WM_REPAINTLEGEND , 0L , 0L ); } }
void wxTreeListCtrl::UpdateItemParentStateRecursively(wxTreeListItem item) { wxCHECK_RET( item.IsOk(), "Invalid item" ); wxASSERT_MSG( HasFlag(wxTL_3STATE), "Can only be used with wxTL_3STATE" ); for ( ;; ) { wxTreeListItem parent = GetItemParent(item); if ( parent == GetRootItem() ) { // There is no checked state associated with the root item. return; } // Set parent state to the state of this item if all the other children // have the same state too. Otherwise make it indeterminate. const wxCheckBoxState stateItem = GetCheckedState(item); CheckItem(parent, AreAllChildrenInState(parent, stateItem) ? stateItem : wxCHK_UNDETERMINED); // And do the same thing with the parent's parent too. item = parent; } }
void addConstraint(std::map<int,T> const& expr, T const& lb, T const& ub) { if (isFalse) return; T min = 0; T max = 0; for (typename std::map<int,T>::const_iterator t = expr.begin(); t != expr.end(); ++t) { T const& w = t->second; if (w > 0) max += w; else if (w < 0) min += w; } if (lb <= min && max <= ub) return; if (ub < lb || max < lb || ub < min) { isFalse = true; return; } if (expr.empty()) return; min = 0; max = 0; bool fc = true; for (typename std::map<int,T>::const_iterator t = expr.begin(); t != expr.end(); ++t) { Checklist& list = checklists[t->first]; T const& w = t->second; list.push_back(CheckItem(constraintId, w, min, max, lb, ub, fc)); if (w > 0) max += w; else if (w < 0) min += w; fc = false; } ++constraintId; }
bool CSideBar::CheckRadioItem(int First,int Last,int Check) { if (First>Last) return false; for (int i=First;i<=Last;i++) CheckItem(i,i==Check); return true; }
//--------------------------------------------------------------------------- bool __fastcall ItemIsAllowedEx(int Lev,bool Out) { bool Res = CheckItem(Lev,false); if (!Res && !ActionAllowedEx(Lev,Out)) { return false; } return true; }
void Route::AddItem( UniqueRouteItem _it ) { CheckItem( _it ); const Station & arriveStation = _it->GetArriveStation(); m_items.push_back( std::move( _it ) ); m_itemsByStation.insert( std::make_pair( & arriveStation, m_items.rbegin()->get() ) ); }
INT_PTR CRecordingSettingsDialog::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { const CTSTaskCentreSettings &Settings=m_Core.GetSettings(); CheckItem(IDC_SETTINGS_RECORDING_CONFIRM_CHANNEL_CHANGE, Settings.Recording.GetConfirmChannelChange()); CheckItem(IDC_SETTINGS_RECORDING_CONFIRM_EXIT, Settings.Recording.GetConfirmExit()); CheckItem(IDC_SETTINGS_RECORDING_CONFIRM_STOP, Settings.Recording.GetConfirmStop()); } return TRUE; } return FALSE; }
//--------------------------------------------------------------------------- bool __fastcall ActionAllowedEx(int Lev,bool Out) { TFormPassWord* Frm = new TFormPassWord(Application); bool Result = false; if (Frm->ShowModal() == mrOk) { Result = CheckItem(Lev,Out); } delete Frm; return Result; }
/* =============== ED_CallSpawn Finds the spawn function for the entity and calls it =============== */ void ED_CallSpawn (edict_t * ent) { spawn_t *s; gitem_t *item; int i; if (!ent->classname) { gi.dprintf ("ED_CallSpawn: NULL classname\n"); return; } // zucc - BD's item replacement idea CheckItem (ent); // check item spawn functions for (i = 0, item = itemlist; i < game.num_items; i++, item++) { if (!item->classname) continue; if (!strcmp (item->classname, ent->classname)) { // found it //FIREBLADE if (!teamplay->value || teamdm->value || ctf->value == 2) { //FIREBLADE if (item->flags == IT_AMMO || item->flags == IT_WEAPON || item->flags == IT_FLAG /*|| item->flags == IT_ITEM || item->flags == IT_POWERUP*/) SpawnItem (ent, item); } else if (ctf->value && item->flags == IT_FLAG) { SpawnItem (ent, item); } return; } } // check normal spawn functions for (s = spawns; s->name; s++) { if (!strcmp (s->name, ent->classname)) { // found it s->spawn (ent); return; } } //AQ2:TNG - Igor adding wp_flags/itm_flags if (strcmp (ent->classname, "freed") != 0) { gi.dprintf ("%s doesn't have a spawn function\n", ent->classname); } //AQ2:TNG End adding flags }
// update dlg with selected item static void FillOptionDialogByCurrentSel(HWND hwndDlg) { int index = SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETCURSEL, 0, 0); int itemData = SendDlgItemMessage(hwndDlg, IDC_ITEMS, LB_GETITEMDATA, index, 0); if (itemData != ID_EXTBKSEPARATOR) { LastModifiedItem = itemData - ID_EXTBK_FIRST; if (CheckItem(itemData - ID_EXTBK_FIRST, hwndDlg)) FillOptionDialogByStatusItem(hwndDlg, StatusItems[itemData - ID_EXTBK_FIRST]); } }
void JXDisplayMenu::Receive ( JBroadcaster* sender, const Message& message ) { const JPtrArray<JXDisplay>* displayList = (JXGetApplication())->GetDisplayList(); if (sender == this && message.Is(JXMenu::kNeedsUpdate)) { Broadcast(DisplayNeedsUpdate()); CheckItem(itsDisplayIndex); } else if (sender == this && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); ChooseDisplay(selection->GetIndex()); } else if (sender == const_cast<JPtrArray<JXDisplay>*>(displayList)) { // we do this no matter what change occurs BuildMenu(); } else if (sender == itsNewDisplayDialog && message.Is(JXDialogDirector::kDeactivated)) { const JXDialogDirector::Deactivated* info = dynamic_cast<const JXDialogDirector::Deactivated*>(&message); assert( info != NULL ); if (info->Successful()) { itsDisplayIndex = itsNewDisplayDialog->GetDisplayIndex(); Broadcast(DisplayChanged(itsDisplayIndex)); } SetPopupChoice(itsDisplayIndex); itsNewDisplayDialog = NULL; } else { JXTextMenu::Receive(sender, message); } }
/* =============== ED_CallSpawn Finds the spawn function for the entity and calls it =============== */ void ED_CallSpawn (edict_t *ent) { spawn_t *s; gitem_t *item; int i; if (!ent->classname) { gi.dprintf ("ED_CallSpawn: NULL classname\n"); return; } // check item spawn functions for (i=0,item=itemlist ; i<game.num_items ; i++,item++) { if (!item->classname) continue; if (!strcmp(item->classname, ent->classname)) { // found it //FIREBLADE if (!teamplay->value) { //FIREBLADE if ( item->flags == IT_AMMO || item->flags == IT_WEAPON ) SpawnItem (ent, item); } return; } // zucc - BD's item replacement idea else { CheckItem(ent, item); } } // check normal spawn functions for (s=spawns ; s->name ; s++) { if (!strcmp(s->name, ent->classname)) { // found it s->spawn (ent); return; } } gi.dprintf ("%s doesn't have a spawn function\n", ent->classname); }
void CBioAPISampleMFCView::OnLButtonDown(UINT nFlags, CPoint point) { UINT uFlags = 0; int nHitItem = GetListCtrl().HitTest(point, &uFlags); // we need additional checking in owner-draw mode // because we only get LVHT_ONITEM BOOL bHit = FALSE; if (uFlags & LVHT_ONITEMSTATEICON) bHit = TRUE; if (bHit) CheckItem(nHitItem); else CListView::OnLButtonDown(nFlags, point); }
void check_menu_item( short menu, short item, NMBoolean checked) { #if OP_PLATFORM_MAC_CFM || OP_PLATFORM_MAC_MACHO #ifndef OP_PLATFORM_MAC_CARBON_FLAG CheckItem(GetMenuHandle(menu), item, checked); #else CheckMenuItem(GetMenuHandle(menu), item, checked); #endif #elif defined(OP_PLATFORM_WINDOWS) CheckMenuItem(GetMenu(screen_window), MAKE_MENU_COMMAND(menu, item), MF_BYCOMMAND | (checked ? MF_CHECKED : MF_UNCHECKED)); #endif return; }
void CTablemapCompletenessChecker::CheckSetOfItems(CString prefix, int last_index, CString postfix, bool mandatory) { // All other items are also mandatory // if the first optional item exists CString first_optional_item; first_optional_item.Format("%s%i%s", prefix, 0, postfix); if (p_tablemap->ItemExists(first_optional_item)) { mandatory = true; } if (!mandatory) return; for (int i=0; i<=last_index; ++i) { CheckItem(prefix, i, postfix); } }
void CRowListView::OnLButtonDblClk(UINT nFlags, CPoint point) { UINT uFlags = 0; int nHitItem = GetListCtrl().HitTest(point, &uFlags); if (uFlags & LVHT_ONITEM) { // double click works only if we don't have state icons, // or if we are in icon or small icon view if (!m_bStateIcons || GetViewType() == LVS_ICON || GetViewType()==LVS_SMALLICON) { CheckItem(nHitItem); } } CListViewEx::OnLButtonDblClk(nFlags, point); }
itemType ItemMgr::RemoveItem(uint32 tileX, uint32 tileY) { BAMItem *pItem; itemType type; pItem = CheckItem(tileX, tileY); if(!pItem) return(NO_ITEM); // delete from our master list lItems.Delete((void *)pItem->gSelf); // delete from ViewPort list pWorld->vPort.CutAni(pItem->gSelf); gItemMap[tileY][tileX] = NULL; type = pItem->type; DeleteItem(pItem); return(type); }
void SCComponentMenu::Receive ( JBroadcaster* sender, const Message& message ) { JBroadcaster* compList = itsCircuit->GetComponentList(); // insure that it isn't const if (sender == this && message.Is(JXMenu::kNeedsUpdate)) { itsBroadcastCompChangeFlag = kJFalse; Broadcast(ComponentNeedsUpdate()); CheckItem(itsMenuIndex); itsBroadcastCompChangeFlag = kJTrue; } else if (sender == this && message.Is(JXMenu::kItemSelected)) { const JXMenu::ItemSelected* selection = dynamic_cast<const JXMenu::ItemSelected*>(&message); assert( selection != NULL ); itsMenuIndex = selection->GetIndex(); JIndex compIndex; const JBoolean ok = MenuIndexToCompIndex(itsMenuIndex, &compIndex); assert( ok ); Broadcast(ComponentChanged(compIndex)); } else if (sender == compList) { JIndex compIndex; const JBoolean ok = MenuIndexToCompIndex(itsMenuIndex, &compIndex); BuildCompList(); if (!ok) { itsMenuIndex = 1; } else if (message.Is(JOrderedSetT::kElementsInserted)) { const JOrderedSetT::ElementsInserted* info = dynamic_cast<const JOrderedSetT::ElementsInserted*>(&message); assert( info != NULL && info->GetCount() == 1 ); info->AdjustIndex(&compIndex); const JBoolean ok = CompIndexToMenuIndex(compIndex, &itsMenuIndex); assert( ok ); } else if (message.Is(JOrderedSetT::kElementsRemoved)) { const JOrderedSetT::ElementsRemoved* info = dynamic_cast<const JOrderedSetT::ElementsRemoved*>(&message); assert( info != NULL && info->GetCount() == 1 ); if (info->AdjustIndex(&compIndex)) { const JBoolean ok = CompIndexToMenuIndex(compIndex, &itsMenuIndex); assert( ok ); } else { itsMenuIndex = 1; } } else if (message.Is(JOrderedSetT::kElementMoved)) { const JOrderedSetT::ElementMoved* info = dynamic_cast<const JOrderedSetT::ElementMoved*>(&message); assert( info != NULL ); info->AdjustIndex(&compIndex); const JBoolean ok = CompIndexToMenuIndex(compIndex, &itsMenuIndex); assert( ok ); } else if (message.Is(JOrderedSetT::kElementsSwapped)) { const JOrderedSetT::ElementsSwapped* info = dynamic_cast<const JOrderedSetT::ElementsSwapped*>(&message); assert( info != NULL ); info->AdjustIndex(&compIndex); const JBoolean ok = CompIndexToMenuIndex(compIndex, &itsMenuIndex); assert( ok ); } else if (message.Is(JOrderedSetT::kSorted)) { assert( 0 ); } // nothing extra required for JOrderedSetT::kElementChanged const JIndex savedIndex = itsMenuIndex; BuildMenu(); itsMenuIndex = savedIndex; if (itsCompList->IndexValid(itsMenuIndex)) { SetPopupChoice(itsMenuIndex); } } else { JXTextMenu::Receive(sender, message); } }
void CUITrade::UpdateAmendConditionCount( int nAmendIndex ) { if (m_pList[eLIST_AMEND_CONDITION] == NULL) return; if (nAmendIndex < 0 && m_pList[eLIST_AMEND_ITEM] != NULL) nAmendIndex = m_pList[eLIST_AMEND_ITEM]->getCurSel(); if (m_pBtnOk != NULL) m_pBtnOk->SetEnable(IsAmend(nAmendIndex) ? TRUE : FALSE); if (nAmendIndex < 0) return; stEventTrade* pTradeItem = CTradeItem::GetTradeItem(nAmendIndex); if (pTradeItem == NULL) return; CUIListItem* pItemTmp = NULL; int i; int nListCnt = m_pList[eLIST_AMEND_CONDITION]->getListItemCount(); CUIText* pText = NULL; for (i = 0; i < DEF_CONDITION_ITEM_MAX; ++i) { if (pTradeItem->st_source_item[i].src_item_idx <= 0 || i > nListCnt) continue; pItemTmp = (CUIListItem*)m_pList[eLIST_AMEND_CONDITION]->GetListItem(i); if (pItemTmp == NULL) continue; COLOR strCol = 0x00FF21FF; int nMyItemCount = UIMGR()->GetInventory()->GetItemCount(pTradeItem->st_source_item[i].src_item_idx); if (CheckItem(nAmendIndex, i) == false) strCol = DEF_UI_COLOR_RED; if (pText = (CUIText*)pItemTmp->findUI("text_item_cnt")) { CTString strTmp; strTmp.PrintF("%d/%d", nMyItemCount, pTradeItem->st_source_item[i].src_item_cnt); pText->SetText(strTmp); pText->setFontColor(strCol); } if (pText = (CUIText*)pItemTmp->findUI("text_name")) { CTString strTmp = _pNetwork->GetItemName(pTradeItem->st_source_item[i].src_item_idx); strTmp = UtilHelp::getSingleton()->GetCalcStringEllipsis(strTmp, pText->GetWidth(), CTString("...")); pText->SetText(strTmp); pText->setFontColor(strCol); } } }
//-------------------------------------------------------------------// // AddItemsFromDragData() // //-------------------------------------------------------------------// // Does the actual work of ripping items from the drag data and // adding them to the list control. //-------------------------------------------------------------------// bool OleListCtrl::AddItemsFromDragData( int nUnderCursor, bool bInsertAfter, CPoint DropPoint ) { InsertStart(); // Loop variables. CRect ItemRect; bool bFirstItem = true; // If nUnderCursor is not valid, we should be at the bottom of // the list. if ( nUnderCursor < 0 ) nUnderCursor = GetItemCount(); // Adjust nUnderCursor to always be before. if ( bInsertAfter ) nUnderCursor++; // Add the items to the list. int i; for ( i = 0; i < Items.GetSize(); i++ ) { // Add it to the list. // The string contains all column text. Break it // back down. CString* pstrFull = &Items[i].m_strName; int nStartPos = pstrFull->Find( ctColumnSeparator ); CString strText = pstrFull->Left( nStartPos ); // We need to include the text and // the data stored in the lParam. int nNewIndex = InsertItem( LVIF_TEXT | LVIF_PARAM, // UINT nMask, nUnderCursor + i, // int nItem, LPCTSTR( strText ), // LPCTSTR lpszItem, 0, // UINT nState, 0, // UINT nStateMask, 0, // int nImage, Items[i].m_lParam // LPARAM lParam ); ASSERT( nNewIndex == nUnderCursor + i ); // Set the checked state. CheckItem( nNewIndex, Items[i].m_bChecked ); // Mark all the dropped items as selected. // WARNING: Don't try to do this until later, so we don't // end up adding to the original moved selection that is // to be deleted. m_vnNewlyDroppedItems.push_back( nNewIndex ); // Set the text of the subitems, if any. int nStopPos; int nCol; for ( nCol = 1; nCol < GetAbsoluteColCount(); nCol++ ) { // Get the next stop position. nStopPos = pstrFull->Find( ctColumnSeparator, nStartPos + 1 ); // Extract the col string. if ( nStopPos == -1 ) strText = pstrFull->Mid( nStartPos + 1 ); else strText = pstrFull->Mid( nStartPos + 1, nStopPos - nStartPos - 1 ); // Do the deed. SetItemText( nUnderCursor + i, nCol, strText ); // Set up for next col. nStartPos = nStopPos; } // Set the position of the item based on the drop // point and the number in the RefItems array. // The first item needs a different calc. We didn't do it // outside the loop because it was easier to get the size // of the item bitmap here. if ( bFirstItem ) { // Calculate the starting drop point. bFirstItem = false; GetItemRect( 0, &ItemRect, LVIR_ICON ); DropPoint.x -= ( ItemRect.Width() / 2 ); DropPoint.y -= ( ItemRect.Height() / 2 ); } else { // This aligns multiple items out to the right. DropPoint.x += ItemRect.Width() + nDropXMargin; } // Now set it, if available. if ( (GetStyle() & LVS_OWNERDATA)==0 ) SetItemPosition( nUnderCursor + i, DropPoint ); // Provide a post-insert-item virtual function. OnAddDroppedItem( nUnderCursor + i ); } InsertEnd(); // We want to return true only if we processed items. // bFirstItem can tell us this. return !bFirstItem; }
INT_PTR CInformationBarSettingsDialog::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { const CTSTaskCentreSettings &Settings=m_Core.GetSettings(); Settings.MainBoard.GetInformationBarFont(&m_CurrentFont); m_InformationBar.SetItemMargin(m_Core.ScaleDPI(m_InformationBar.GetDefaultItemMargin())); m_InformationBar.SetFont(m_CurrentFont); m_InformationBar.Create(hDlg); m_ItemMargin=MapDialogUnitX(2); ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST, LB_SETITEMHEIGHT,0,m_InformationBar.GetHeight()+m_ItemMargin*2); CMainBoardSettings::InformationBarItemList ItemList; Settings.MainBoard.GetInformationBarItemList(&ItemList); for (size_t i=0;i<ItemList.size();i++) { CMainBoardSettings::InformationBarItemInfo *pItemInfo= new CMainBoardSettings::InformationBarItemInfo(ItemList[i]); ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST, LB_ADDSTRING,0,reinterpret_cast<LPARAM>(pItemInfo)); InformationBarItems::CCustomInformationItem *pItem= new InformationBarItems::CCustomInformationItem(0); pItem->SetFormat(pItemInfo->Format.c_str()); m_InformationBar.AddItem(pItem); } static const LPCTSTR TextAlignList[] = { TEXT("����"),TEXT("�E��"),TEXT("����"), }; for (int i=0;i<_countof(TextAlignList);i++) { ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_TEXT_ALIGN, CB_ADDSTRING,0,reinterpret_cast<LPARAM>(TextAlignList[i])); } ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_WIDTH_SPIN, UDM_SETRANGE32,0,10000); SetItemInfo(); SetFontInfo(hDlg,IDC_SETTINGS_INFORMATION_BAR_FONT_INFO,m_CurrentFont); SetTimeComboBox(hDlg,IDC_SETTINGS_INFORMATION_BAR_UPDATE_INTERVAL, 1,10,Settings.MainBoard.GetInformationBarUpdateInterval()); CheckItem(IDC_SETTINGS_INFORMATION_BAR_SHOW_ERROR, Settings.MainBoard.GetInformationBarShowError()); SetTimeComboBox(hDlg,IDC_SETTINGS_INFORMATION_BAR_ERROR_DURATION, 1,10,Settings.MainBoard.GetInformationBarErrorDuration()); EnableItems(IDC_SETTINGS_INFORMATION_BAR_ERROR_DURATION_LABEL, IDC_SETTINGS_INFORMATION_BAR_ERROR_DURATION, Settings.MainBoard.GetInformationBarShowError()); } return TRUE; case WM_DRAWITEM: { LPDRAWITEMSTRUCT pdis=reinterpret_cast<LPDRAWITEMSTRUCT>(lParam); if (wParam==IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST) { switch (pdis->itemAction) { case ODA_DRAWENTIRE: case ODA_SELECT: { const bool fSelected=(pdis->itemState & ODS_SELECTED)!=0; ::FillRect(pdis->hDC,&pdis->rcItem, reinterpret_cast<HBRUSH>( static_cast<INT_PTR>((fSelected?COLOR_HIGHLIGHT:COLOR_WINDOW)+1))); if ((int)pdis->itemID>=0) { const CMainBoardSettings::InformationBarItemInfo *pItemInfo= reinterpret_cast<const CMainBoardSettings::InformationBarItemInfo*>(pdis->itemData); InformationBarItems::CCustomInformationItem *pItem= static_cast<InformationBarItems::CCustomInformationItem*>(m_InformationBar.GetItem(pdis->itemID)); if (pItem==nullptr) break; pItem->SetTextAlign(CInformationBar::CItem::TextAlign(pItemInfo->TextAlign)); RECT rcItem=pdis->rcItem; ::InflateRect(&rcItem,-m_ItemMargin,-m_ItemMargin); RECT rcMargin=m_InformationBar.GetItemMargin(); rcItem.right=rcItem.left+ (pItemInfo->Width<0?CInformationBar::CItem::DEFAULT_WIDTH:pItemInfo->Width)+ rcMargin.left+rcMargin.right; m_InformationBar.DrawItemPreview(pItem,pdis->hDC,rcItem); } } if ((pdis->itemState & ODS_FOCUS)==0) break; case ODA_FOCUS: if ((pdis->itemState & ODS_NOFOCUSRECT)==0) ::DrawFocusRect(pdis->hDC,&pdis->rcItem); break; } } } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST: if (HIWORD(wParam)==LBN_SELCHANGE) { SetItemInfo(); } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_NEW_ITEM: { CMainBoardSettings::InformationBarItemInfo *pItemInfo= new CMainBoardSettings::InformationBarItemInfo; pItemInfo->TextAlign=0; LRESULT Index=::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST, LB_ADDSTRING,0,reinterpret_cast<LPARAM>(pItemInfo)); ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST, LB_SETCURSEL,Index,0); InformationBarItems::CCustomInformationItem *pItem= new InformationBarItems::CCustomInformationItem(0); m_InformationBar.AddItem(pItem); SetItemInfo(); } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_DELETE_ITEM: { LRESULT Sel=::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST,LB_GETCURSEL,0,0); if (Sel>=0) { delete reinterpret_cast<CMainBoardSettings::InformationBarItemInfo*>( ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST,LB_GETITEMDATA,Sel,0)); ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST,LB_DELETESTRING,Sel,0); m_InformationBar.DeleteItem(Sel); SetItemInfo(); } } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_MOVE_UP_ITEM: case IDC_SETTINGS_INFORMATION_BAR_MOVE_DOWN_ITEM: { HWND hwndList=GetItemHandle(IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST); bool fUp=LOWORD(wParam)==IDC_SETTINGS_INFORMATION_BAR_MOVE_UP_ITEM; LRESULT Sel=::SendMessage(hwndList,LB_GETCURSEL,0,0); LRESULT To; if (fUp) { if (Sel<1) return TRUE; To=Sel-1; } else { if (Sel<0 || Sel+1>=::SendMessage(hwndList,LB_GETCOUNT,0,0)) return TRUE; To=Sel+1; } ::SendMessage(hwndList,WM_SETREDRAW,FALSE,0); LRESULT ItemData=::SendMessage(hwndList,LB_GETITEMDATA,Sel,0); ::SendMessage(hwndList,LB_DELETESTRING,Sel,0); ::SendMessage(hwndList,LB_INSERTSTRING,To,ItemData); ::SendMessage(hwndList,LB_SETCURSEL,To,0); UpdateItemFormat(int(Sel)); UpdateItemFormat(int(To)); ::SendMessage(hwndList,WM_SETREDRAW,TRUE,0); ::InvalidateRect(hwndList,nullptr,TRUE); SetItemInfo(); } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_FORMAT: if (HIWORD(wParam)==EN_CHANGE) { CMainBoardSettings::InformationBarItemInfo *pItem=GetSelectedItem(); if (pItem!=nullptr) { GetItemString(IDC_SETTINGS_INFORMATION_BAR_FORMAT,&pItem->Format); UpdateItemFormat((int)::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST,LB_GETCURSEL,0,0)); UpdateSelectedItem(); } } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_FORMAT_MENU: { HMENU hmenu=::CreatePopupMenu(); InformationBarItems::CCustomInformationItem::ParameterInfo Info; for (int i=0;InformationBarItems::CCustomInformationItem::GetParameterInfo(i,&Info);i++) { WCHAR szText[128]; TSTask::FormatString(szText,_countof(szText),L"%s\t%s", Info.pszParameter,Info.pszText); ::AppendMenu(hmenu,MF_STRING | MF_ENABLED,i+1,szText); } RECT rc; ::GetWindowRect(GetItemHandle(IDC_SETTINGS_INFORMATION_BAR_FORMAT_MENU),&rc); int Result=::TrackPopupMenu(hmenu,TPM_RETURNCMD,rc.left,rc.bottom,0,hDlg,nullptr); ::DestroyMenu(hmenu); if (Result>0 && InformationBarItems::CCustomInformationItem::GetParameterInfo(Result-1,&Info)) { HWND hwndEdit=GetItemHandle(IDC_SETTINGS_INFORMATION_BAR_FORMAT); DWORD Start,End; ::SetFocus(hwndEdit); ::SendMessage(hwndEdit,EM_GETSEL, reinterpret_cast<WPARAM>(&Start),reinterpret_cast<LPARAM>(&End)); ::SendMessage(hwndEdit,EM_REPLACESEL, TRUE,reinterpret_cast<LPARAM>(Info.pszParameter)); if (End<Start) Start=End; ::SendMessage(hwndEdit,EM_SETSEL, Start,Start+::lstrlen(Info.pszParameter)); } } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_TEXT_ALIGN: if (HIWORD(wParam)==CBN_SELCHANGE) { CMainBoardSettings::InformationBarItemInfo *pItem=GetSelectedItem(); if (pItem!=nullptr) { pItem->TextAlign= (int)::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_TEXT_ALIGN,CB_GETCURSEL,0,0); UpdateSelectedItem(); } } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_ITEM_WIDTH: if (HIWORD(wParam)==EN_CHANGE) { CMainBoardSettings::InformationBarItemInfo *pItem=GetSelectedItem(); if (pItem!=nullptr) { pItem->Width=GetItemInt(IDC_SETTINGS_INFORMATION_BAR_ITEM_WIDTH); UpdateSelectedItem(); } } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_CHOOSE_FONT: if (ChooseFontDialog(hDlg,&m_CurrentFont)) { SetFontInfo(hDlg,IDC_SETTINGS_INFORMATION_BAR_FONT_INFO,m_CurrentFont); m_InformationBar.SetFont(m_CurrentFont); ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST, LB_SETITEMHEIGHT,0,m_InformationBar.GetHeight()+m_ItemMargin*2); ::InvalidateRect(GetItemHandle(IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST),nullptr,TRUE); } return TRUE; case IDC_SETTINGS_INFORMATION_BAR_SHOW_ERROR: EnableItems(IDC_SETTINGS_INFORMATION_BAR_ERROR_DURATION_LABEL, IDC_SETTINGS_INFORMATION_BAR_ERROR_DURATION, IsItemChecked(IDC_SETTINGS_INFORMATION_BAR_SHOW_ERROR)); } return TRUE; case WM_DESTROY: { int ItemCount=(int)::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST,LB_GETCOUNT,0,0); for (int i=0;i<ItemCount;i++) { delete reinterpret_cast<CMainBoardSettings::InformationBarItemInfo*>( ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST,LB_GETITEMDATA,i,0)); } ::SendDlgItemMessage(hDlg,IDC_SETTINGS_INFORMATION_BAR_ITEM_LIST,LB_RESETCONTENT,0,0); m_InformationBar.DeleteAllItems(); } return TRUE; } return FALSE; }