void CManageFiltersDlg::OnCustomDraw(NMHDR *pNotifyStruct, LRESULT *pLResult) { NMLVCUSTOMDRAW *pLVCD = reinterpret_cast<NMLVCUSTOMDRAW *>(pNotifyStruct); *pLResult = CDRF_DODEFAULT; const int iItem = (int)pLVCD->nmcd.dwItemSpec; const int iSubItem = pLVCD->iSubItem; bool bCopy(false), bExport(false), bActive(false); st_FilterItemData *pflt_idata(NULL); switch(pLVCD->nmcd.dwDrawStage) { case CDDS_ITEMPREPAINT: case CDDS_ITEMPREPAINT | CDDS_SUBITEM: pflt_idata = (st_FilterItemData *)m_FilterLC.GetItemData(iItem); bActive = (pflt_idata->flt_flags & MFLT_INUSE) == MFLT_INUSE; bCopy = (pflt_idata->flt_flags & MFLT_REQUEST_COPY_TO_DB) == MFLT_REQUEST_COPY_TO_DB; bExport = (pflt_idata->flt_flags & MFLT_REQUEST_EXPORT) == MFLT_REQUEST_EXPORT; break; default: break; } int ix, iy; const COLORREF crLightGreen = RGB(222, 255, 222); switch(pLVCD->nmcd.dwDrawStage) { case CDDS_PREPAINT: *pLResult = CDRF_NOTIFYITEMDRAW; break; case CDDS_ITEMPREPAINT: pLVCD->clrText = ::GetSysColor(COLOR_WINDOWTEXT); // Show selected item on light green background if (iItem == m_selectedfilter) { pLVCD->clrTextBk = crLightGreen; } else { pLVCD->clrTextBk = m_FilterLC.GetTextBkColor(); } *pLResult = CDRF_NOTIFYSUBITEMDRAW; break; case CDDS_ITEMPREPAINT | CDDS_SUBITEM: { CRect rect; m_FilterLC.GetSubItemRect(iItem, iSubItem, LVIR_BOUNDS, rect); if (rect.top < 0) { *pLResult = CDRF_SKIPDEFAULT; break; } if (iSubItem == 0) { CRect rect1; m_FilterLC.GetSubItemRect(iItem, 1, LVIR_BOUNDS, rect1); rect.right = rect1.left; } CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc); CRect inner_rect(rect), first_rect(rect); inner_rect.DeflateRect(2, 2); switch (iSubItem) { case MFLC_FILTER_NAME: case MFLC_FILTER_SOURCE: break; case MFLC_INUSE: // Make text 'invisible' pLVCD->clrText = pLVCD->clrTextBk; // Show selected item on light green background if (iItem == m_selectedfilter) { pDC->FillSolidRect(&first_rect, crLightGreen); } // Draw checked/unchecked image ix = inner_rect.CenterPoint().x; iy = inner_rect.CenterPoint().y; // The '7' below is ~ half the bitmap size of 13. inner_rect.SetRect(ix - 7, iy - 7, ix + 7, iy + 7); DrawImage(pDC, inner_rect, bActive ? CHECKED : EMPTY); *pLResult = CDRF_SKIPDEFAULT; break; case MFLC_COPYTODATABASE: // Make text 'invisible' pLVCD->clrText = pLVCD->clrTextBk; // Show selected item on light green background if (iItem == m_selectedfilter) { pDC->FillSolidRect(&first_rect, crLightGreen); } *pLResult = CDRF_SKIPDEFAULT; // If already a database filter - don't need any image if (pflt_idata->flt_key.fpool == FPOOL_DATABASE) break; // Draw checked/unchecked image ix = inner_rect.CenterPoint().x; iy = inner_rect.CenterPoint().y; // The '7' below is ~ half the bitmap size of 13. inner_rect.SetRect(ix - 7, iy - 7, ix + 7, iy + 7); // Set image according to DB being R-O or not CheckImage nImage; if (m_bDBReadOnly) nImage = bCopy ? CHECKED_DISABLED : EMPTY_DISABLED; else nImage = bCopy ? CHECKED : EMPTY; DrawImage(pDC, inner_rect, nImage); break; case MFLC_EXPORT: // Make text 'invisible' pLVCD->clrText = pLVCD->clrTextBk; // Show selected item on light green background if (iItem == m_selectedfilter) { pDC->FillSolidRect(&first_rect, crLightGreen); } // Draw checked/unchecked image ix = inner_rect.CenterPoint().x; iy = inner_rect.CenterPoint().y; // The '7' below is ~ half the bitmap size of 13. inner_rect.SetRect(ix - 7, iy - 7, ix + 7, iy + 7); DrawImage(pDC, inner_rect, bExport ? CHECKED : EMPTY); *pLResult = CDRF_SKIPDEFAULT; break; default: break; } } break; default: break; } }
BOOL MacWidgetPainter::DrawDropdown(const OpRect &drawrect) { OpSkinElement *border_skin = widget->GetBorderSkin()->GetSkinElement(); if(!g_skin_manager->GetCurrentSkin() || !border_skin || !border_skin->IsNative()) { return IndpWidgetPainter::DrawDropdown(drawrect); } OpDropDown* dropdown = (OpDropDown*) widget; INT32 left = 0; INT32 top = 0; INT32 right = 0; INT32 bottom = 0; dropdown->GetBorderSkin()->GetPadding(&left, &top, &right, &bottom); // Fix for bug 249063, Pop-up menus have wrong padding /* if(dropdown->GetFormObject()) { left += 5; right += 3; } */ OpRect inner_rect(drawrect.x + left, drawrect.y + top, drawrect.width - left - right, drawrect.height - top - bottom); if (inner_rect.width < 0 || inner_rect.height < 0) return FALSE; if (dropdown->GetForegroundSkin()->HasContent()) { inner_rect.x += 2; inner_rect.width -= 2; OpRect image_rect = dropdown->GetForegroundSkin()->CalculateScaledRect(inner_rect, FALSE, TRUE); if (widget->GetRTL()) image_rect.x = drawrect.Right() - image_rect.Right() + drawrect.x; dropdown->GetForegroundSkin()->Draw(vd, image_rect); UINT32 image_width = image_rect.width + 4; inner_rect.x += image_width; inner_rect.width -= image_width; } if (widget->GetRTL()) inner_rect.width -= GetInfo()->GetDropdownLeftButtonWidth(widget); else inner_rect.width -= GetInfo()->GetDropdownButtonWidth(widget); inner_rect.height--; OpStringItem* item = dropdown->GetItemToPaint(); if (!dropdown->edit && (item || dropdown->ghost_string.Get())) { OpRect item_rect = inner_rect; if (widget->GetRTL()) item_rect.x = drawrect.Right() - item_rect.Right() + drawrect.x; dropdown->SetClipRect(item_rect); if (item) { dropdown->GetPainterManager()->DrawItem(item_rect, item, FALSE, FALSE); } else { OpRect string_rect = inner_rect; dropdown->AddMargin(&string_rect); if (widget->GetRTL()) string_rect.x = drawrect.Right() - string_rect.Right() + drawrect.x; dropdown->ghost_string.Draw(string_rect, vd, g_op_ui_info->GetSystemColor(OP_SYSTEM_COLOR_UI_DISABLED_FONT)); } dropdown->RemoveClipRect(); } OpRect button_rect = drawrect; const char* button_image = widget->GetRTL() ? "Dropdown Left Button Skin" : "Dropdown Button Skin"; widget->GetSkinManager()->GetMargin(button_image, &left, &top, &right, &bottom); button_rect.y += top; button_rect.height -= top + bottom; button_rect.x += button_rect.width - GetInfo()->GetDropdownButtonWidth(widget) - right; button_rect.width = GetInfo()->GetDropdownButtonWidth(widget); INT32 state = 0; if (!widget->IsEnabled()) state |= SKINSTATE_DISABLED; if (dropdown->m_dropdown_window) state |= SKINSTATE_PRESSED; INT32 hover_value = 0; if (dropdown->m_dropdown_packed.is_hovering_button) { state |= SKINSTATE_HOVER; hover_value = 100; } if(dropdown->edit && !dropdown->edit->IsReadOnly()) { const char *skin_image = widget->GetBorderSkin()->GetImage(); #ifdef WIDGETS_CAP_HAS_BOTH_CUSTOM_AND_DEFAULT_DROPDOWN // only draw the dropdown arrow if this is a special editable drop down. This should be placed with a generic // check of the skin once arjanl has commited his code if(!skin_image || !uni_strcmp(skin_image, UNI_L("Zoom Dropdown Skin")) || !uni_strcmp(skin_image, UNI_L("Dropdown Addressfield Skin")) || !uni_strcmp(skin_image, UNI_L("Dropdown Search Skin"))) #else // only draw the dropdown arrow if this is an editable dropdown if(!skin_image || uni_strcmp(skin_image, UNI_L("Dropdown Search Field Skin"))) #endif // WIDGETS_CAP_HAS_BOTH_CUSTOM_AND_DEFAULT_DROPDOWN { if (widget->GetRTL()) button_rect.x = drawrect.Right() - button_rect.Right() + drawrect.x; widget->GetSkinManager()->DrawElement(vd, button_image, button_rect, state, hover_value); } #if 1 // Put focusrect in the right place (dropdowns are different from pure editfields) OpRect newrect = drawrect.InsetBy(-2, -2); if(skin_image && (!uni_strcmp(skin_image, UNI_L("Dropdown Search Skin")) || !uni_strcmp(skin_image, UNI_L("Dropdown Search Field Skin")))) DrawRoundedFocusRect(newrect, dropdown->edit->IsFocused() || widget->IsFocused()); else if (dropdown->edit->IsFocused() || widget->IsFocused()) DrawFocusRect(newrect); #endif } return TRUE; }