bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) return false; CFX_WideString opt_value = GetOptionValue(index); if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value)) return false; if (bSelected) { if (GetType() == ListBox) { SelectOption(index, true); if (!(m_Flags & kFormListMultiSelect)) { m_pDict->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false); } else { CPDF_Array* pArray = m_pDict->SetNewFor<CPDF_Array>("V"); for (int i = 0; i < CountOptions(); i++) { if (i == index || IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false); } } } } else { m_pDict->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false); CPDF_Array* pI = m_pDict->SetNewFor<CPDF_Array>("I"); pI->AddNew<CPDF_Number>(index); } } else { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (GetType() == ListBox) { SelectOption(index, false); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) m_pDict->RemoveFor("V"); } else if (pValue->IsArray()) { std::unique_ptr<CPDF_Array> pArray(new CPDF_Array); for (int i = 0; i < CountOptions(); i++) { if (i != index && IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddNew<CPDF_String>(PDF_EncodeText(opt_value), false); } } if (pArray->GetCount() > 0) m_pDict->SetFor("V", std::move(pArray)); } } else { m_pDict->RemoveFor("V"); m_pDict->RemoveFor("I"); } } } if (bNotify) NotifyListOrComboBoxAfterChange(); return true; }
void _ArpControllerRangeList::SelectionChanged() { inherited::SelectionChanged(); int32 selection = CurrentSelection(); BMessage update('iupd'); if (selection >= 0) { BListItem* item; for (int32 k = 0; (item = ItemAt(k)); k++) { _ArpControllerRangeItem* ccItem = dynamic_cast<_ArpControllerRangeItem*>(item); if (ccItem) { if ( IsItemSelected(k) ) { update.AddInt32(mSettingsKey.String(), k); if ( !ccItem->IsActive() ) { ccItem->SetActive(true); InvalidateItem(k); } } else { if ( ccItem->IsActive() ) { ccItem->SetActive(false); InvalidateItem(k); } } } } } if (mTarget) { mTarget->Implementation().SendConfiguration(&update); mTarget->Settings().Update(update); } }
/*********************************************************** * FindNextSelection ***********************************************************/ int32 HListView::FindNextSelection(int32 index) { int32 count = CountItems(); for (int32 i = index + 1; i < count; i++) { if (IsItemSelected(i)) return i; } return -1; }
void CSVGElementListView::SelectItem(int index/*ILSVGElement* item*/) { CSVGListViewItem* pItem = m_items[index]; ATLASSERT(!IsItemSelected(pItem)); m_selectedItems.Add(pItem); InvalidateRect(&m_areaRect); }
PRUint64 nsXFormsItemRadiogroupAccessible::NativeState() { PRUint64 state = nsXFormsSelectableItemAccessible::NativeState(); if (IsItemSelected()) state |= states::CHECKED; return state; }
nsresult nsXFormsItemRadiogroupAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, aExtraState); NS_ENSURE_A11Y_SUCCESS(rv, rv); if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_CHECKED; return NS_OK; }
NS_IMETHODIMP nsXFormsItemCheckgroupAccessible::GetActionName(PRUint8 aIndex, nsAString& aName) { if (aIndex != eAction_Click) return NS_ERROR_INVALID_ARG; if (IsItemSelected()) aName.AssignLiteral("uncheck"); else aName.AssignLiteral("check"); return NS_OK; }
void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, bool bSelected) { if (!IsValid(nItemIndex)) return; if (bSelected != IsItemSelected(nItemIndex)) { if (bSelected) { SetItemSelect(nItemIndex, true); InvalidateItem(nItemIndex); } else { SetItemSelect(nItemIndex, false); InvalidateItem(nItemIndex); } } }
PRUint64 nsXFormsItemComboboxAccessible::NativeState() { PRUint64 state = nsXFormsSelectableItemAccessible::NativeState(); if (state & states::UNAVAILABLE) return state; state |= states::SELECTABLE; if (IsItemSelected()) state |= states::SELECTED; return state; }
NS_IMETHODIMP nsXFormsItemRadiogroupAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsSelectableItemAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); if (!mDOMNode) return NS_OK; if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_CHECKED; return NS_OK; }
//处理combox逻辑显示 void SecurityChange::everyListWidgetSlot(QListWidgetItem*) { if(IsItemSelected(ui->topSecuListWidget)) { fileSecuComboBoxshow(1); } else if(IsItemSelected(ui->confidentialListWidget)) { fileSecuComboBoxshow(2); } else if(IsItemSelected(ui->secretListWidget)) { fileSecuComboBoxshow(3); } else if(IsItemSelected(ui->insideListWidget)) { fileSecuComboBoxshow(4); } else { fileSecuComboBoxshow(5); } }
NS_IMETHODIMP nsXFormsItemComboboxAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsSelectableItemAccessible::GetState(aState, aExtraState); NS_ENSURE_SUCCESS(rv, rv); if (!mDOMNode || (*aState & nsIAccessibleStates::STATE_UNAVAILABLE)) return NS_OK; *aState |= nsIAccessibleStates::STATE_SELECTABLE; if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_SELECTED; return NS_OK; }
void wxMacDataBrowserListControl::ListSetSelection( unsigned int n, bool select, bool multi ) { wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n); wxMacDataItemBrowserSelectionSuppressor suppressor(this); if ( IsItemSelected( item ) != select ) { if ( select ) SetSelectedItem( item, multi ? kDataBrowserItemsAdd : kDataBrowserItemsAssign ); else SetSelectedItem( item, kDataBrowserItemsRemove ); } ListScrollTo( n ); }
void CFX_ListCtrl::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) { int32_t nHitIndex = GetItemIndex(point); if (IsMultipleSel()) { if (bCtrl) { if (IsItemSelected(nHitIndex)) { m_aSelItems.Sub(nHitIndex); SelectItems(); m_bCtrlSel = FALSE; } else { m_aSelItems.Add(nHitIndex); SelectItems(); m_bCtrlSel = TRUE; } m_nFootIndex = nHitIndex; } else if (bShift) { m_aSelItems.DeselectAll(); m_aSelItems.Add(m_nFootIndex,nHitIndex); SelectItems(); } else { m_aSelItems.DeselectAll(); m_aSelItems.Add(nHitIndex); SelectItems(); m_nFootIndex = nHitIndex; } SetCaret(nHitIndex); } else { SetSingleSelect(nHitIndex); } if (!IsItemVisible(nHitIndex)) ScrollToListItem(nHitIndex); }
void CFileListManager::OnMousePressed( vgui::MouseCode code ) { // determine where we were pressed int x, y, row, column; vgui::input()->GetCursorPos( x, y ); GetCellAtPos( x, y, row, column ); if ( code == MOUSE_LEFT ) { bool bIsFakeToggleButton = column == CI_LOADED; if ( bIsFakeToggleButton && row >= 0 && row < GetItemCount() ) { int itemID = GetItemIDFromRow( row ); KeyValues *kv = GetItem( itemID ); const char *pStr = kv->GetString( GetKey( ( ColumnIndex_t )column ), "" ); Assert( *pStr == 'Y' || *pStr == 'N' ); bool bSet = *pStr == 'N'; // bSet is the NEW state, not the old one kv->SetString( GetKey( ( ColumnIndex_t )column ), bSet ? "Y" : "N" ); SetLoaded( ( DmFileId_t )GetItemUserData( itemID ), bSet ); // get the key focus RequestFocus(); return; } } else if ( code == MOUSE_RIGHT ) { int itemID = -1; if ( row >= 0 && row < GetItemCount() ) { itemID = GetItemIDFromRow( row ); if ( !IsItemSelected( itemID ) ) { SetSingleSelectedItem( itemID ); } } KeyValues *kv = new KeyValues( "OpenContextMenu", "itemID", itemID ); OnOpenContextMenu( kv ); kv->deleteThis(); return; } BaseClass::OnMousePressed( code ); }
nsresult nsXFormsItemComboboxAccessible::GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState) { nsresult rv = nsXFormsSelectableItemAccessible::GetStateInternal(aState, aExtraState); NS_ENSURE_A11Y_SUCCESS(rv, rv); if (*aState & nsIAccessibleStates::STATE_UNAVAILABLE) return NS_OK; *aState |= nsIAccessibleStates::STATE_SELECTABLE; if (IsItemSelected()) *aState |= nsIAccessibleStates::STATE_SELECTED; return NS_OK; }
// CHgzListCtrl 消息处理程序 void CHgzListCtrl::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 BOOL bSelected = FALSE; // 得到被点击的Item LVHITTESTINFO testinfo; testinfo.pt = point; //点击时的鼠标位置 //testinfo.flags = LVHT_ONITEM; //点击的必须不是标题 if( SubItemHitTest(&testinfo)<0 ) goto defalt_session; //没有点在有效区域,不进入编辑 // 检查是否有Item正被编辑 if (m_bEditing == TRUE) { if (m_nItem == testinfo.iItem && m_nSubItem == testinfo.iSubItem) goto defalt_session; else EndEdit(TRUE); } int m = m_nItem; int n = m_nSubItem; m_nItem = testinfo.iItem; //被点击表项的行号 m_nSubItem = testinfo.iSubItem; //被点击表项的列号 Update(m); if(m_nSubItem == 0) { bSelected = IsItemSelected(m_nItem) && GetSelectedCount() == 1; goto defalt_session; //点中第一列,不编辑 } // 开始编辑 CListCtrl::OnLButtonDown(nFlags, point); m_bEditing = BeginEdit(); return; defalt_session: CListCtrl::OnLButtonDown(nFlags, point); if (m_nSubItem == 0 && bSelected) { SetItemState(m_nItem, 0, LVIS_SELECTED); SetItemState(m_nItem, 0, LVIS_FOCUSED); } }
void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected) { if (!IsValid(nItemIndex)) return; if (bSelected != IsItemSelected(nItemIndex)) { if (bSelected) { SetItemSelect(nItemIndex,TRUE); InvalidateItem(nItemIndex); } else { SetItemSelect(nItemIndex,FALSE); InvalidateItem(nItemIndex); } } }
void CControlGalleryUndo::OnSelectedItemChanged() { CXTPControlStatic* pInfo = FindInfoControl(); if (pInfo) { CString str; if (!IsItemSelected()) { str = _T("Cancel"); } else { str.Format(_T("Undo %i Actions"), GetSelectedItem() + 1); } pInfo->SetCaption(str); pInfo->RedrawParent(FALSE); } }
void TrackListCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { TRACEST(_T("TrackListCtrl::OnContextMenu")); if (m_pPlayer == NULL) return; CPoint htp(point); ScreenToClient(&htp); m_menuInitiator = GetItemFromPoint(htp.x, htp.y); if (m_menuInitiator == -1) return; if (IsItemSelected(m_menuInitiator) == FALSE) SetItemSelection(m_menuInitiator, TRUE); ITSMenu& mainMenu = GetInternalMenu(M_Main); mainMenu.TrackPopupMenu(point.x, point.y, pWnd->GetSafeHwnd()); }
MsgRouting AwtList::HandleEvent(MSG *msg, BOOL synthetic) { if (IsFocusingMouseMessage(msg)) { LONG item = static_cast<LONG>(SendListMessage(LB_ITEMFROMPOINT, 0, msg->lParam)); if (item != LB_ERR) { if (isMultiSelect) { if (IsItemSelected(item)) { Deselect(item); } else { Select(item); } } else { Select(item); } } delete msg; return mrConsume; } if (msg->message == WM_KEYDOWN && msg->wParam == VK_RETURN) { WmNotify(LBN_DBLCLK); } return AwtComponent::HandleEvent(msg, synthetic); }
void AwtList::SetMultiSelect(BOOL ms) { if (ms == isMultiSelect) { return; } JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); /* Copy current box's contents to string array */ const int nCount = GetCount(); LPTSTR * strings = new LPTSTR[nCount]; int i; for(i = 0; i < nCount; i++) { LRESULT len = SendListMessage(LB_GETTEXTLEN, i); LPTSTR text = NULL; try { text = new TCHAR[len + 1]; } catch (std::bad_alloc&) { // free char * already allocated for (int j = 0; j < i; j++) { delete [] strings[j]; } delete [] strings; throw; } VERIFY(SendListMessage(LB_GETTEXT, i, (LPARAM)text) != LB_ERR); strings[i] = text; } // index for selected item after multi-select mode change int toSelect = SendListMessage(LB_GETCURSEL); if (!isMultiSelect) { // MSDN: for single-select lists LB_GETCURSEL returns // index of selected item or LB_ERR if no item is selected if (toSelect == LB_ERR) { toSelect = -1; } } else { // MSDN: for multi-select lists LB_GETCURSEL returns index // of the focused item or 0 if no items are selected; if // some item has focus and is not selected then LB_GETCURSEL // return its index, so we need IsItemSelected too if ((toSelect == LB_ERR) || (SendListMessage(LB_GETSELCOUNT) == 0) || (IsItemSelected(toSelect) == 0)) { toSelect = -1; } } isMultiSelect = ms; HWND parentHWnd = GetParent()->GetHWnd(); /* Save old list box's attributes */ RECT rect; GetWindowRect(GetListHandle(), &rect); MapWindowPoints(0, parentHWnd, (LPPOINT)&rect, 2); HANDLE font = (HANDLE)SendListMessage(WM_GETFONT); LRESULT itemHeight = SendListMessage(LB_GETITEMHEIGHT, 0); DWORD style = ::GetWindowLong(GetListHandle(), GWL_STYLE) | WS_VSCROLL | WS_HSCROLL; if (isMultiSelect) { style |= LBS_MULTIPLESEL; } else { style &= ~LBS_MULTIPLESEL; } DWORD exStyle = ::GetWindowLong(GetListHandle(), GWL_EXSTYLE); jobject peer = GetPeer(env); UnsubclassHWND(); AwtToolkit::DestroyComponentHWND(m_hwnd); CreateHWnd(env, L"", style, exStyle, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, parentHWnd, NULL, ::GetSysColor(COLOR_WINDOWTEXT), ::GetSysColor(COLOR_WINDOW), peer); SendListMessage(WM_SETFONT, (WPARAM)font, (LPARAM)FALSE); SendListMessage(LB_SETITEMHEIGHT, 0, MAKELPARAM(itemHeight, 0)); SendListMessage(LB_RESETCONTENT); for (i = 0; i < nCount; i++) { InsertString(i, strings[i]); delete [] strings[i]; } delete[] strings; if (toSelect != -1) { Select(toSelect); } AdjustHorizontalScrollbar(); }
void CCxNDArrayDimGrid::OnLButtonDown(UINT nFlags, CPoint point) { //CBCGPGridCtrl::OnLButtonDown(nFlags, point); CWnd::OnLButtonDown(nFlags, point); OnFilterBarSetFocus (-1); SetFocus (); //-------------------- // Group-by-box click: //-------------------- CRect rectColumn; int nGroupHit = HitTestGroupByBox (point, rectColumn); if (nGroupHit >= 0) { m_ptStartDrag = point; StartDragColumn (nGroupHit, rectColumn, TRUE, FALSE); return; } // ------------- // Track header: // ------------- CPoint ptHeader = point; if (OnTrackHeader () && m_rectList.PtInRect (point)) { ptHeader.y = m_rectHeader.top; } int nColumnHit = GetColumnsInfo ().HitTestColumn (ptHeader, TRUE, STRETCH_DELTA); if (nColumnHit != -1) { int nLButton = GetSystemMetrics (SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON; if ((GetAsyncKeyState (nLButton) & 0x8000) == 0) { return; } if (!GetColumnsInfo ().CanChangeWidth (nColumnHit)) { // column can't be resized return; } CRect rectHeaderColumn; GetColumnsInfo ().GetColumnRect (nColumnHit, rectHeaderColumn); SetCapture (); m_nTrackColumn = nColumnHit; TrackHeader (rectHeaderColumn.right); m_bTracking = TRUE; return; } if (IsDragSelectionBorderEnabled () && HitTestSelectionBorder (point)) { if (StartDragItems (point)) { return; } } //-------------- // Header click: //-------------- CBCGPGridColumnsInfo::ClickArea clickAreaHeader; nColumnHit = GetColumnsInfo ().HitTestColumn (point, FALSE, STRETCH_DELTA, &clickAreaHeader); if (nColumnHit >= 0) { DoColumnHeaderClick (nColumnHit, point, clickAreaHeader); return; } //------------------------- // "Select all" area click: //------------------------- if (m_rectSelectAllArea.PtInRect (point)) { OnSelectAllClick (); return; } //------------------ // Row header click: //------------------ CRect rectRowHeader; CCxNDArrayDimRow* pHitHeaderRow = (CCxNDArrayDimRow*)HitTestRowHeader (point, rectRowHeader); if (pHitHeaderRow != NULL) { DoRowHeaderClick (pHitHeaderRow, point, rectRowHeader); return; } // --------------------------- // Set selection (first click): // --------------------------- CBCGPGridRow::ClickArea clickArea; CBCGPGridItemID id; CBCGPGridItem* pHitItem = NULL; CBCGPGridRow* pHitRow = HitTest (point, id, pHitItem, &clickArea); BOOL bSelChanged = id != m_idLastSel; BOOL bIsButtonClick = pHitItem != NULL && ((CCxNDArrayDimItem*)pHitItem)->m_rectButton.PtInRect (point); const BOOL bShift = (::GetAsyncKeyState (VK_SHIFT) & 0x8000) != 0 && !m_bIgnoreShiftBtn; const BOOL bCtrl = (::GetAsyncKeyState (VK_CONTROL) & 0x8000) != 0 && !m_bIgnoreCtrlBtn; if (IsDragSelectionEnabled () && IsItemSelected (id) && !(bCtrl && m_bInvertSelOnCtrl)) { if (StartDragItems (point)) { return; } } DWORD dwSelMode = SM_NONE; if (!id.IsNull ()) { dwSelMode = SM_FIRST_CLICK | (m_bSingleSel ? SM_SINGE_SEL_GROUP : (bCtrl ? SM_ADD_SEL_GROUP : (bShift ? SM_CONTINUE_SEL_GROUP : SM_SINGE_SEL_GROUP))); if (bCtrl && m_bInvertSelOnCtrl) { dwSelMode |= SM_INVERT_SEL; } if (pHitRow != NULL && id.IsRow ()) { dwSelMode |= SM_ROW; } if (id.IsColumn ()) { dwSelMode |= SM_COLUMN; } } m_bNoUpdateWindow = TRUE; // prevent flickering m_pSetSelItem = m_bVirtualMode ? NULL : pHitItem; SetCurSel (id, dwSelMode); m_pSetSelItem = NULL; m_bNoUpdateWindow = FALSE; if (id.IsNull () || pHitRow == NULL) { return; } ASSERT_VALID (pHitRow); EnsureVisible (pHitRow); CCxNDArrayDimRow* pCurSel = (CCxNDArrayDimRow*)GetCurSel (); CCxNDArrayDimItem* pItem = ( CCxNDArrayDimItem* )GetCurSelItem (pCurSel); if (id != m_idActive || pCurSel == NULL || (pItem == NULL && clickArea == CBCGPGridRow::ClickValue)) { // The hitten item is not active - do not translate a click to the grid item. // Translate a click for single item only. return; } // ------------------------------ // Translate a click to the item: // ------------------------------ ASSERT_VALID (pCurSel); // pCurSel - hitten row switch (clickArea) { case CBCGPGridRow::ClickExpandBox: pCurSel->Expand (!pCurSel->IsExpanded ()); break; case CBCGPGridRow::ClickName: pCurSel->OnClickName (point); // Start selecting range of items: StartSelectItems (); break; case CBCGPGridRow::ClickValue: ASSERT_VALID (pItem); // pItem - hitten active item if (pCurSel->m_bEnabled && pItem->IsEnabled ()) { if (bIsButtonClick || m_bSingleSel) { DoClickValue (pItem, WM_LBUTTONDOWN, point, bSelChanged, bIsButtonClick); } else { // Defer the item click: SetTimer (GRID_CLICKVALUE_TIMER_ID, GRID_CLICKVALUE_TIMER_INTERVAL, NULL); m_bClickTimer = TRUE; m_ptClickOnce = point; m_bIsFirstClick = bSelChanged; m_bIsButtonClick = bIsButtonClick; m_bHeaderRowSelecting = FALSE; m_bHeaderColSelecting = FALSE; StartSelectItems (); return; } } break; default: break; } }
bool wxMacDataBrowserListControl::ListIsSelected( unsigned int n ) const { wxMacDataItem* item = (wxMacDataItem*) GetItemFromLine(n); return IsItemSelected( item ); }
LRESULT CSVGElementListView::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CPaintDC dc(m_hWnd); long scrollposY; m_vert->get_pos(&scrollposY); if (dc.IntersectClipRect(&m_areaRect) > NULLREGION) { dc.SetViewportOrg(m_areaRect.left, m_areaRect.top -scrollposY); HFONT hOldFont = dc.GetCurrentFont(); CFont font = (HFONT)GetStockObject(DEFAULT_GUI_FONT); LOGFONT lf; font.GetLogFont(&lf); lf.lfWeight = FW_BOLD; CFont boldFont; boldFont.CreateFontIndirect(&lf); dc.SetBkMode(TRANSPARENT); int itemHeight = (m_view == 0 || m_view == 2)? SMALL: LARGE; int ncolumns = m_areaRect.Width()/itemHeight; if (ncolumns == 0) ncolumns = 1; for (int i = 0; i < m_items.GetSize(); i++) { int x, y; int x2, y2; int twidth, theight; if (m_view == 0 || m_view == 1) // Small/Large Thumbnails { x = i%ncolumns *itemHeight; y = i/ncolumns *itemHeight; x2 = x+3; y2 = y+3; twidth = itemHeight-6; theight = itemHeight-6; } else // Small/Large ListView { x = 0; y = i*itemHeight; x2 = x+3; y2 = y+3; twidth = itemHeight-6; theight = itemHeight-6; } bool bSelected = IsItemSelected(m_items[i]); _bstr_t id; /* if (m_items[i]->m_element) { BSTR bid; m_items[i]->m_element->getAttribute(L"id", &bid); id = _bstr_t(bid, false); } else */ { id = m_items[i]->m_name; } if (m_view == 2 || m_view == 3) // Small/Large Listview, display id { dc.MoveTo(0, y); dc.LineTo(m_areaRect.Width(), y); dc.FillSolidRect(0, y+1, m_areaRect.Width(), itemHeight-1, GetSysColor(COLOR_WINDOW)); dc.Draw3dRect(x2-1, y2-1, twidth+2, theight+2, RGB(0, 0, 0), RGB(0, 0, 0)); if (bSelected) { dc.SelectFont(boldFont); dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT)); dc.SetBkColor(GetSysColor(COLOR_HIGHLIGHT)); dc.FillSolidRect(0, y+2, m_areaRect.Width(), itemHeight-3, dc.GetBkColor()); } else { dc.SelectFont(font); dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); dc.SetBkColor(GetSysColor(COLOR_WINDOW)); } CRect trect(itemHeight+2, y+3, m_areaRect.Width(), y+itemHeight-3); dc.DrawText(id, id.length(), &trect, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS); } else // Thumbnails { dc.Draw3dRect(x, y, itemHeight, itemHeight, RGB(0, 0, 0), RGB(0, 0, 0)); if (bSelected) { dc.Draw3dRect(x+2, y+2, itemHeight-4, itemHeight-4, RGB(0,0,0), RGB(0,0,0)); } } DRAWITEMSTRUCT dis; dis.hDC = dc.m_hDC; dis.rcItem = CRect(x2, y2, x2+twidth, y2+theight); dis.itemData = (ULONG_PTR)m_items[i]; ::SendMessage(GetParent(), WM_DRAWITEM, 0, (LPARAM)&dis); } dc.SelectFont(hOldFont); } return 0; }
void CSVGElementListView::ButtonDown(UINT nFlags, CPoint point) { long scrollposY; m_vert->get_pos(&scrollposY); point.x += -m_areaRect.left; point.y += -m_areaRect.top + scrollposY; int itemHeight = (m_view == 0 || m_view == 2)? SMALL: LARGE; int itemIndex; if (m_view == 0 || m_view == 1) // Small/Large Thumbnails { int ncolumns = m_areaRect.Width()/itemHeight; if (ncolumns == 0) ncolumns = 1; itemIndex = (point.y / itemHeight)*ncolumns + point.x/itemHeight; } else // Small/Large ListView { itemIndex = (point.y / itemHeight); } if (itemIndex >= 0 && itemIndex < m_items.GetSize()) { CSVGListViewItem* pItem = m_items[itemIndex]; //CComPtr<ILSVGElement> item = m_items[itemIndex]->m_element; BOOL bSelected = IsItemSelected(pItem); if (!m_multiSelect) { if (!bSelected) { DeselectAll(); SelectItem(itemIndex/*pItem*/); m_selectedItemIndex = itemIndex; //Fire_ClickSwatch(swatch); } } else { if (nFlags & MK_CONTROL) // Toggle selected { if (bSelected) { DeselectItem(pItem); } else { SelectItem(itemIndex); if (m_selectedItemIndex == -1) m_selectedItemIndex = itemIndex; //Fire_ClickSwatch(swatch); } } else { long startSel, endSel; if (!(nFlags & MK_SHIFT) || (m_selectedItemIndex == -1)) { startSel = endSel = itemIndex; } else if (itemIndex > m_selectedItemIndex) { startSel = m_selectedItemIndex; endSel = itemIndex; } else { startSel = itemIndex; endSel = m_selectedItemIndex; } DeselectAll(); for (long i = startSel; i <= endSel; i++) { //CComPtr<ILSVGElement> item = m_items[i]->m_element; SelectItem(i); } if (!(nFlags & MK_SHIFT) || (m_selectedItemIndex == -1)) m_selectedItemIndex = itemIndex; //Fire_ClickSwatch(swatch); } } InvalidateRect(&m_areaRect); } }
FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) return FALSE; CFX_WideString opt_value = GetOptionValue(index); if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value)) return FALSE; if (bSelected) { if (GetType() == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & kFormListMultiSelect)) { m_pDict->SetStringFor("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { if (i == index || IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } m_pDict->SetFor("V", pArray); } } else { m_pDict->SetStringFor("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; pI->AddInteger(index); m_pDict->SetFor("I", pI); } } else { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (GetType() == ListBox) { SelectOption(index, FALSE); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) m_pDict->RemoveFor("V"); } else if (pValue->IsArray()) { std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray( new CPDF_Array); for (int i = 0; i < CountOptions(); i++) { if (i != index && IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } if (pArray->GetCount() > 0) m_pDict->SetFor("V", pArray.release()); // std::move someday } } else { m_pDict->RemoveFor("V"); m_pDict->RemoveFor("I"); } } } if (bNotify) NotifyListOrComboBoxAfterChange(); return TRUE; }
void TrackListCtrl::DrawItem(Gdiplus::Graphics& g, INT nItem, Gdiplus::Rect& itemRC) { HDC hdc = g.GetHDC(); if (hdc == 0) { TRACE(_T("@1 TrackListCtrl::DrawItem. Cant get HDC\r\n")); return; } CDC* pDC = CDC::FromHandle(hdc); PrgAPI* pAPI = PRGAPI(); //Calculate Colors BOOL bSelected = IsItemSelected(nItem); COLORREF clrText = m_colors[COL_Text]; COLORREF clrBk = m_colors[COL_Bk]; if (bSelected) { clrText = m_colors[COL_TextSel]; clrBk = m_colors[COL_TextSelBk]; } CRect rcSubItem(itemRC.X, itemRC.Y, itemRC.GetRight(), itemRC.GetBottom()); pDC->SetTextColor(clrText); pDC->FillSolidRect(rcSubItem, clrBk); const INT cMargin = 2; FullTrackRecordSP& rec = (*m_pCollection)[nItem]; pDC->SetBkMode(TRANSPARENT); INT curx = cMargin; CRect rcFirstLine(rcSubItem); rcFirstLine.bottom = rcFirstLine.top + 20; rcFirstLine.left = cMargin; rcFirstLine.right -= cMargin; CRect rcSecondLine(rcSubItem); rcSecondLine.top = rcFirstLine.bottom; rcSecondLine.left = cMargin; rcSecondLine.right -= cMargin; if (m_bDrawPictures) { INT imgHeight = 32;//rcSubItem.Height() - 2 * cMargin; INT cury = rcSubItem.top + cMargin; LocalPictureManager* pLM = PRGAPI()->GetLocalPictureManager(); Gdiplus::Rect rcImage(curx, cury, imgHeight, imgHeight); Graphics g2(hdc); BOOL bRet = pLM->DrawAlbumThumbnail(rec->artist.name.c_str(), rec->album.name.c_str(), g2, rcImage); if (!bRet) bRet = pLM->DrawArtistThumbnail(rec->artist.name.c_str(), g2, rcImage); if (!bRet) bRet = pLM->DrawDefaultThumbnail(IIT_AlbumPicture, g2, rcImage); curx += 32 + cMargin ; } rcSecondLine.left = curx; //=== Draw the icon INT cury = rcFirstLine.top + (rcFirstLine.Height() - 16) / 2; pDC->SetTextColor(clrText); DrawIconEx(pDC->m_hDC, curx, cury, pAPI->GetIconForTrackType(rec->track.trackType), 16, 16, 0, 0, DI_NORMAL); curx += 16 + cMargin; //=== Draw the title CRect rcTitle(rcFirstLine); rcTitle.left = curx; CFont* pOldFont = pDC->SelectObject(m_pBoldFont); pDC->DrawText(rec->track.name.c_str(), rec->track.name.size(), &rcTitle, DT_END_ELLIPSIS | DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); pDC->DrawText(rec->track.name.c_str(), rec->track.name.size(), &rcTitle, DT_END_ELLIPSIS | DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT); //=== Draw the artist CRect rcArtist(rcFirstLine); rcArtist.left = rcTitle.right + cMargin; pDC->DrawText(rec->artist.name.c_str(), rec->artist.name.size(), &rcArtist, DT_END_ELLIPSIS | DT_RIGHT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); pDC->SelectObject(m_pNormalFont); //=== Next line //=== Draw the rating (if exists) if (rec->track.rating > 0 && rec->track.rating < 256) { FLOAT fStars = Rating2Stars(rec->track.rating); if (fStars > 0.0f && fStars <=1.0f) { DrawIconEx(hdc, rcSecondLine.left, rcSecondLine.top, pAPI->GetIcon(ICO_StarBad16), 16, 16, 0, 0, DI_NORMAL); rcSecondLine.left += 17; } while (fStars > 1.0f) { DrawIconEx(hdc, rcSecondLine.left, rcSecondLine.top, pAPI->GetIcon(ICO_StarGold16), 16, 16, 0, 0, DI_NORMAL); fStars -= 1.0f; rcSecondLine.left += 17; } } TCHAR time[500]; UINT len = _sntprintf(time, 500, _T("%d:%02d | %s: %s | %s: %s"), INT (rec->track.duration / 60), INT(rec->track.duration) % 60, pAPI->GetString(IDS_ALBUM), rec->album.name.c_str(), pAPI->GetString(IDS_LOCATION), rec->track.location.c_str() ); pDC->DrawText(time, len, &rcSecondLine, DT_END_ELLIPSIS | DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); pDC->SelectObject(pOldFont); g.ReleaseHDC(pDC->m_hDC); }
FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) { return FALSE; } CFX_WideString opt_value = GetOptionValue(index); if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; if (GetType() == ListBox) { iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, opt_value); } if (GetType() == ComboBox) { iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, opt_value); } if (iRet < 0) { return FALSE; } } if (!bSelected) { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (m_Type == ListBox) { SelectOption(index, FALSE); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) { m_pDict->RemoveAt("V"); } } else if (pValue->IsArray()) { CPDF_Array* pArray = new CPDF_Array; int iCount = CountOptions(); for (int i = 0; i < iCount; i++) { if (i != index) { if (IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } } if (pArray->GetCount() < 1) { pArray->Release(); } else { m_pDict->SetAt("V", pArray); } } } else if (m_Type == ComboBox) { m_pDict->RemoveAt("V"); m_pDict->RemoveAt("I"); } } } else { if (m_Type == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & FORMLIST_MULTISELECT)) { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; int iCount = CountOptions(); for (int i = 0; i < iCount; i++) { FX_BOOL bSelected; if (i != index) { bSelected = IsItemSelected(i); } else { bSelected = TRUE; } if (bSelected) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } m_pDict->SetAt("V", pArray); } } else if (m_Type == ComboBox) { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; pI->AddInteger(index); m_pDict->SetAt("I", pI); } } if (bNotify && m_pForm->m_pFormNotify) { if (GetType() == ListBox) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } if (GetType() == ComboBox) { m_pForm->m_pFormNotify->AfterValueChange(this); } } if (CPDF_InterForm::m_bUpdateAP) { UpdateAP(NULL); } m_pForm->m_bUpdated = TRUE; return TRUE; }
FX_BOOL CPDF_FormField::SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify) { ASSERT(GetType() == ComboBox || GetType() == ListBox); if (index < 0 || index >= CountOptions()) return FALSE; CFX_WideString opt_value = GetOptionValue(index); if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value)) return FALSE; if (bSelected) { if (GetType() == ListBox) { SelectOption(index, TRUE); if (!(m_Flags & FORMLIST_MULTISELECT)) { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); } else { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { if (i == index || IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } m_pDict->SetAt("V", pArray); } } else { m_pDict->SetAtString("V", PDF_EncodeText(opt_value)); CPDF_Array* pI = new CPDF_Array; pI->AddInteger(index); m_pDict->SetAt("I", pI); } } else { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); if (pValue) { if (GetType() == ListBox) { SelectOption(index, FALSE); if (pValue->IsString()) { if (pValue->GetUnicodeText() == opt_value) m_pDict->RemoveAt("V"); } else if (pValue->IsArray()) { CPDF_Array* pArray = new CPDF_Array; for (int i = 0; i < CountOptions(); i++) { if (i != index && IsItemSelected(i)) { opt_value = GetOptionValue(i); pArray->AddString(PDF_EncodeText(opt_value)); } } if (pArray->GetCount() < 1) pArray->Release(); else m_pDict->SetAt("V", pArray); } } else { m_pDict->RemoveAt("V"); m_pDict->RemoveAt("I"); } } } if (bNotify) NotifyListOrComboBoxAfterChange(); return TRUE; }