bool TffdshowPageDec::invInter(TconfPageBase *page, RECT *r) { if (!page) { page = this->page; } if (page->invInter()) { InvalidateRect(htv, r, FALSE); setDlgResult(TRUE); return true; } else { return false; } }
INT_PTR TffdshowPageEnc::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_HSCROLL: if (HWND(lParam) == GetDlgItem(m_hwnd, IDC_TBR_QUICK)) { if (valIdff) { cfgSet(valIdff, tbrGet(IDC_TBR_QUICK)); quick2dlg(false); } return TRUE; } break; case WM_FFONCHANGE: if (wParam == IDFF_lang && ve) { ve->commonOptionChanged(IID_IffdshowEnc, IDFF_lang); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CBX_ENCODER: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_codecId, ((Tencoder*)cbxGetCurItemData(IDC_CBX_ENCODER))->id); codec2dlg(); HTREEITEM hti = TreeView_GetSelection(htv); if (hti) { selectPage(hti2page(hti)); } return TRUE; } break; case IDC_CBX_FOURCC: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_fourcc, (int)cbxGetCurItemData(IDC_CBX_FOURCC)); fourcc2dlg(); return TRUE; } break; case IDC_CBX_MODES: if (HIWORD(wParam) == CBN_SELCHANGE) { cfgSet(IDFF_enc_mode, (int)cbxGetCurItemData(IDC_CBX_MODES)); quick2dlg(true); return TRUE; } break; case IDC_ED_QUICK: if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam)); if (hed != GetFocus()) { return FALSE; } repaint(hed); switch (LOWORD(wParam)) { case IDC_ED_QUICK: eval(hed, valMin, valMax, valIdff); tbrSet(IDC_TBR_QUICK, cfgGet(valIdff)); break; } return TRUE; } break; case IDC_BT_PRESET: if (HIWORD(wParam) == BN_CLICKED) { showPresets(); return TRUE; } break; case IDC_CHB_NOT_REGISTRY: cfgSet(IDFF_notreg, getCheck(IDC_CHB_NOT_REGISTRY)); return TRUE; } break; case WM_CTLCOLOREDIT: { HWND hwnd = HWND(lParam); bool ok; switch (getId(hwnd)) { case IDC_ED_QUICK: ok = eval(hwnd, valMin, valMax); break; default: return FALSE; } if (!ok) { HDC dc = HDC(wParam); SetBkColor(dc, RGB(255, 0, 0)); return INT_PTR(getRed()); } else { return FALSE; } } case WM_DRAWITEM: if (wParam == IDC_CBX_ENCODER) { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT*)lParam; COLORREF crOldTextColor = GetTextColor(dis->hDC); COLORREF crOldBkColor = GetBkColor(dis->hDC); HBRUSH br; if ((dis->itemAction | ODA_SELECT) && (dis->itemState & ODS_SELECTED)) { SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); SetBkColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHT)); br = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); } else { br = CreateSolidBrush(crOldBkColor); } FillRect(dis->hDC, &dis->rcItem, br); if (int(dis->itemData) != CB_ERR) { RECT r = dis->rcItem; r.left += 2; Tencoder *enc = (Tencoder*)dis->itemData; DrawText(dis->hDC, enc->name, (int)strlen(enc->name), &r, DT_LEFT | DT_SINGLELINE | DT_VCENTER); setDlgResult(TRUE); r.left += 180; FillRect(dis->hDC, &r, br); MoveToEx(dis->hDC, r.left, r.top, NULL); LineTo(dis->hDC, r.left, r.bottom); SetTextColor(dis->hDC, GetSysColor(COLOR_GRAYTEXT)); r.left += 4; char_t text[70]; SendMessage(hcbxE, CB_GETLBTEXT, dis->itemID, LPARAM(text)); DrawText(dis->hDC, text, (int)strlen(text), &r, DT_LEFT | DT_SINGLELINE | DT_VCENTER); } SetTextColor(dis->hDC, crOldTextColor); SetBkColor(dis->hDC, crOldBkColor); DeleteObject(br); return TRUE; } break; } return TffdshowPageBase::msgProc(uMsg, wParam, lParam); }
INT_PTR TlevelsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: SelectObject(hdcGradient,oldHDCgradient); DeleteDC(hdcGradient); DeleteBitmap(bmpGradient); DeleteFont(fontGradient); SendMessage(GetDlgItem(m_hwnd,IDC_LBX_LEVELS_CURVES),WM_SETFONT,NULL,FALSE); DeleteFont(fontCurier); break; case WM_DRAWITEM: switch (wParam) { case IDC_BMP_HISTOGRAM: { LPDRAWITEMSTRUCT dis=LPDRAWITEMSTRUCT(lParam); int full=cfgGet(IDFF_levelsFullY); StretchDIBits(dis->hDC,0,0,dis->rcItem.right,dis->rcItem.bottom,full?0:16,0,full?256:234-16+1,64,histogramBits,(BITMAPINFO*)&histogramBmp,DIB_RGB_COLORS,SRCCOPY); wIn->draw(dis); return TRUE; } case IDC_BMP_LEVELS_IN: { LPDRAWITEMSTRUCT dis=LPDRAWITEMSTRUCT(lParam); StretchBlt(dis->hDC,0,0,dis->rcItem.right,10,hdcGradient,0,0,256,1,SRCCOPY); RECT r=dis->rcItem; r.top=10; FillRect(dis->hDC,&r,GetSysColorBrush(COLOR_BTNFACE)); if (filter && getCheck(IDC_CHB_LEVELS_INPUT_AUTO)) { int min,max; filter->getInAuto(&min,&max); drawTriangle(dis,min,true); drawTriangle(dis,max,true); } drawTriangle(dis,cfgGet(IDFF_levelsInMin)); drawTriangle(dis,cfgGet(IDFF_levelsInMax)); return TRUE; } case IDC_BMP_LEVELS_OUT: { LPDRAWITEMSTRUCT dis=LPDRAWITEMSTRUCT(lParam); StretchBlt(dis->hDC,0,0,dis->rcItem.right,10,hdcGradient,0,0,256,1,SRCCOPY); RECT r=dis->rcItem; r.top=10; FillRect(dis->hDC,&r,GetSysColorBrush(COLOR_BTNFACE)); drawTriangle(dis,cfgGet(IDFF_levelsOutMin)); drawTriangle(dis,cfgGet(IDFF_levelsOutMax)); return TRUE; } case IDC_BMP_LEVELS_CURVES: { LPDRAWITEMSTRUCT dis=LPDRAWITEMSTRUCT(lParam); StretchDIBits(dis->hDC,0,0,dis->rcItem.right,dis->rcItem.bottom,0,0,256,256,histogramBits,(BITMAPINFO*)&curvesBmp,DIB_RGB_COLORS,SRCCOPY); wCurves->draw(dis); return TRUE; } } break; case WM_SETCURSOR: if (HWND(wParam)==hcurves) { if (wCurves->setCursor()) { SetCursor(LoadCursor(NULL,IDC_SIZEALL)); setDlgResult(TRUE); } return TRUE; } break; } return TconfPageDecVideo::msgProc(uMsg,wParam,lParam); }
INT_PTR TffdshowPageDec::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CBX_PRESETS: if (HIWORD(wParam) == CBN_SELCHANGE) { char_t presetName[256], actPresetName[256]; GetDlgItemText(m_hwnd, IDC_CBX_PRESETS, presetName, 255); deciD->getActivePresetName(actPresetName, 255); if (stricmp(presetName, actPresetName) != 0) { selectPreset(presetName); } return TRUE; } break; } break; case WM_FFONNEWFILTERS: { for (ThtiPages::const_iterator hp = filterPages.begin(); hp != filterPages.end(); hp++) for (TconfPages::const_iterator i = (*hp)->begin(); i != (*hp)->end(); i++) { ((TconfPageDec*)(*i))->onNewFilter(); } return TRUE; } case WM_NOTIFY: { NMHDR *nmhdr = LPNMHDR(lParam); if (nmhdr->hwndFrom == htv && nmhdr->idFrom == IDC_TV_TREE) switch (nmhdr->code) { case TVN_GETINFOTIP: { if (!cfgGet(IDFF_showHints)) { return FALSE; } NMTVGETINFOTIP *nmtvit = LPNMTVGETINFOTIP(lParam); TconfPageBase *page = hti2page(nmtvit->hItem); char_t tipS[1024] = _l(""); if (deciD->getFilterTipEx(page->filterID, page->filterPageID, tipS, 1023) != S_OK) { page->getTip(tipS, 1023); } if (tipS[0] == '\0') { return FALSE; } memset(nmtvit->pszText, 0, nmtvit->cchTextMax); ff_strncpy(nmtvit->pszText, tipS, nmtvit->cchTextMax - 1); return TRUE; } case NM_CUSTOMDRAW: { NMTVCUSTOMDRAW *tvcd = LPNMTVCUSTOMDRAW(lParam); int rcDy = tvcd->nmcd.rc.bottom - tvcd->nmcd.rc.top; if (tvcd->nmcd.dwDrawStage == CDDS_PREPAINT) { setDlgResult(CDRF_NOTIFYITEMDRAW); return TRUE; } else if (tvcd->nmcd.dwDrawStage == CDDS_ITEMPREPAINT) { TconfPageBase *page = ((ThtiPage*)tvcd->nmcd.lItemlParam)->getPage(); if (page->getInter() == -1 && page->getOrder() == -1) { return FALSE; } setDlgResult(CDRF_NOTIFYPOSTPAINT); return TRUE; } else if (tvcd->nmcd.dwDrawStage == CDDS_ITEMPOSTPAINT) { RECT &tr = tvcd->nmcd.rc; if (tr.right > tr.left && tr.bottom > tr.top) { RECT rr; TreeView_GetItemRect(htv, HTREEITEM(tvcd->nmcd.dwItemSpec), &rr, true); rr.left -= 24; TconfPageBase *page = ((ThtiPage*)tvcd->nmcd.lItemlParam)->getPage(); if (page->getInter() != -1) { ImageList_Draw(hil, page->getInter() ? ilChecked : ilClear, tvcd->nmcd.hdc, tr.left + 8 + rr.left, tr.top + (rcDy - 16) / 2, ILD_TRANSPARENT); } if (isIn(page->getOrder(), deciD->getMinOrder2(), deciD->getMaxOrder2()) && (tvcd->nmcd.uItemState & CDIS_SELECTED)) { int img; HTREEITEM hti = page->hti; HTREEITEM htiPrev = TreeView_GetPrevVisible(htv, hti), htiNext = TreeView_GetNextVisible(htv, hti); int order = page->getOrder(), orderPrev = hti2page(htiPrev)->getOrder(), orderNext = hti2page(htiNext)->getOrder(); if (order == deciD->getMinOrder2()) { img = ilArrowD; } else if (order == deciD->getMaxOrder2()) { img = ilArrowU; } else { img = ilArrowUD; } ImageList_DrawEx(hil, img, tvcd->nmcd.hdc, tr.left + 2 + rr.left, tr.top + (rcDy - 16) / 2, 5, 16, CLR_DEFAULT, CLR_DEFAULT, ILD_TRANSPARENT); } } return TRUE; } return FALSE; } case NM_CLICK: { POINT ps; GetCursorPos(&ps); ScreenToClient(htv, &ps); TVHITTESTINFO tvhti; tvhti.pt = ps; HTREEITEM hti = TreeView_HitTest(htv, &tvhti); if (!hti) { return FALSE; } RECT rr; TreeView_GetItemRect(htv, hti, &rr, TRUE); RECT r; TreeView_GetItemRect(htv, hti, &r, FALSE); ps.x -= rr.left - 24; int iconTop = ((r.bottom - r.top) - 16) / 2; ps.y -= r.top; if (ps.x >= 8 && ps.x <= 16 + 8 && ps.y >= iconTop + 2 && ps.y <= iconTop + 13) { if (invInter(hti2page(hti), &r)) { return TRUE; } } else if (ps.x >= 2 && ps.x <= 7 && TreeView_GetSelection(htv) == tvhti.hItem) { int center = (r.bottom - r.top) / 2; if (ps.y > center - 6 && ps.y < center - 1 && page->getOrder() > deciD->getMinOrder2()) { swap(-1); return TRUE; } else if (ps.y > center + 1 && ps.y < center + 6 && page->getOrder() < deciD->getMaxOrder2()) { swap(1); return TRUE; } } return FALSE; } case TVN_BEGINDRAG: { NMTREEVIEW *nmtv = LPNMTREEVIEW(lParam); dragpage = hti2page(nmtv->itemNew.hItem); int order = dragpage->getOrder(); TreeView_SelectItem(htv, nmtv->itemNew.hItem); if (isIn(order, deciD->getMinOrder2(), deciD->getMaxOrder2())) { SetCapture(m_hwnd); } else { dragpage = NULL; } break; } } break; } case WM_MOUSEMOVE: if (dragpage) { TVHITTESTINFO tvhti; tvhti.pt.x = LOWORD(lParam) - tvx; tvhti.pt.y = HIWORD(lParam) - tvy; if (HTREEITEM htiTarget = TreeView_HitTest(htv, &tvhti)) { //TreeView_SelectDropTarget(htv,htiTarget); TconfPageBase *targetpage = hti2page(htiTarget); if (isIn(targetpage->getOrder(), deciD->getMinOrder2(), deciD->getMaxOrder2())) { swap(dragpage, targetpage); } } return TRUE; } break; case WM_LBUTTONUP: if (dragpage) { dragpage = NULL; ReleaseCapture(); return TRUE; } break; } return TffdshowPageBase::msgProc(uMsg, wParam, lParam); }
INT_PTR TdlgPropsEdit::msgProc(UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { hlv=GetDlgItem(m_hwnd,IDC_LV_PROPS); int ncol=0; ListView_AddCol(hlv,ncol,300,_l("Original:/Translation"),false); ListView_SetItemCount(hlv,props.size()*2); ListView_SetExtendedListViewStyleEx(hlv,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: if (HWND(lParam)==GetDlgItem(m_hwnd,IDOK) || HWND(lParam)==GetDlgItem(m_hwnd,IDCANCEL)) { EndDialog(m_hwnd,LOWORD(wParam)); return TRUE; } break; }; break; case WM_NOTIFY: { NMHDR *nmhdr=LPNMHDR(lParam); if (nmhdr->idFrom==IDC_LV_PROPS) switch (nmhdr->code) { case LVN_GETDISPINFO: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; int i=nmdi->item.iItem; if (i==-1) { break; } if (nmdi->item.mask&LVIF_TEXT) switch (nmdi->item.iSubItem) { case 0: { //strcpy(nmdi->item.pszText,((i&1)==0)?props[i/2].first.c_str():props[i/2].second.c_str()); nmdi->item.pszText=(LPTSTR)((i&1)==0?props[i/2].first.c_str():props[i/2].second.c_str()); break; } } return TRUE; } case NM_CUSTOMDRAW: { NMLVCUSTOMDRAW *lvcd=LPNMLVCUSTOMDRAW(lParam); if (lvcd->nmcd.dwDrawStage==CDDS_PREPAINT) { setDlgResult(CDRF_NOTIFYITEMDRAW); return TRUE; } if (lvcd->nmcd.dwDrawStage==CDDS_ITEMPREPAINT) { if (!italicFont) { LOGFONT oldFont; HFONT hf=(HFONT)GetCurrentObject(lvcd->nmcd.hdc,OBJ_FONT); GetObject(hf,sizeof(LOGFONT),&oldFont); oldFont.lfItalic=TRUE; italicFont=CreateFontIndirect(&oldFont); } if ((lvcd->nmcd.dwItemSpec&1)==0) { SelectObject(lvcd->nmcd.hdc,italicFont); } setDlgResult(CDRF_NEWFONT); return TRUE; } return TRUE; } case LVN_BEGINLABELEDIT: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; if ((nmdi->item.iItem&1)==0) { setDlgResult(TRUE); return TRUE; } break; } case LVN_ENDLABELEDIT: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; if (nmdi->item.pszText) { props[nmdi->item.iItem/2].second=nmdi->item.pszText; setDlgResult(TRUE); return TRUE; } break; } case LVN_KEYDOWN: { NMLVKEYDOWN *nmkd=(NMLVKEYDOWN*)lParam; if (nmkd->wVKey==VK_F2) { ListView_EditLabel(hlv,ListView_GetNextItem(hlv,-1,LVNI_SELECTED)); return TRUE; } break; } } break; } } return Twindow::msgProc(uMsg,wParam,lParam); }
INT_PTR TpresetsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: cfgSet(IDFF_lvWidth0,ListView_GetColumnWidth(hlv,0)); if (italicFont) { DeleteObject(italicFont); } italicFont=NULL; if (boldFont) { DeleteObject(boldFont); } boldFont=NULL; break; case WM_NOTIFY: { NMHDR *nmhdr=LPNMHDR(lParam); if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_PRESETS) switch (nmhdr->code) { case LVN_GETDISPINFO: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; int i=nmdi->item.iItem; if (i==-1) { break; } if (nmdi->item.mask&LVIF_TEXT) { strcpy(nmdi->item.pszText,(*parent->localPresets)[i]->presetName); } return TRUE; } case LVN_ITEMCHANGED: { if (nochange) { break; } NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam); if (nmlv->iItem==-1) { return TRUE; } char_t presetName[1024]; ListView_GetItemText(hlv,nmlv->iItem,0,presetName,1023); applying=true; parent->selectPreset(presetName); cfg2dlg(); applying=false; return TRUE; } case LVN_KEYDOWN: { NMLVKEYDOWN *nmkd=(NMLVKEYDOWN*)lParam; switch (nmkd->wVKey) { case VK_F2: ListView_EditLabel(hlv,ListView_GetNextItem(hlv,-1,LVNI_SELECTED)); return TRUE; case VK_SPACE: changePresetState(); return TRUE; } break; } case NM_DBLCLK: case NM_CLICK: { NMITEMACTIVATE *nmia=LPNMITEMACTIVATE(lParam); if (nmia->iItem==-1) { char_t activePresetName[MAX_PATH]; deciD->getActivePresetName(activePresetName, countof(activePresetName)); applying=true; parent->selectPreset(activePresetName); cfg2dlg(); applying=false; } else if (nmhdr->code==NM_DBLCLK) { changePresetState(); } return TRUE; } case LVN_ENDLABELEDIT: { NMLVDISPINFO *nmdi=(NMLVDISPINFO*)lParam; if (!nmdi->item.pszText) { return FALSE; } if (parent->localPresets->getPreset(nmdi->item.pszText,false)==NULL && Tpreset::isValidPresetName(nmdi->item.pszText)) { setDlgResult(TRUE); ffstring presetName; Tpreset::normalizePresetName(presetName,nmdi->item.pszText); renamePreset(presetName.c_str()); } else { setDlgResult(FALSE); } } case NM_CUSTOMDRAW: { NMLVCUSTOMDRAW *lvcd=LPNMLVCUSTOMDRAW(lParam); if (lvcd->nmcd.dwDrawStage==CDDS_PREPAINT) { setDlgResult(CDRF_NOTIFYITEMDRAW); return TRUE; } if (lvcd->nmcd.dwDrawStage==CDDS_ITEMPREPAINT) { if (!italicFont) { LOGFONT oldFont; HFONT hf=(HFONT)GetCurrentObject(lvcd->nmcd.hdc,OBJ_FONT); GetObject(hf,sizeof(LOGFONT),&oldFont); oldFont.lfItalic=TRUE; italicFont=CreateFontIndirect(&oldFont); oldFont.lfItalic=FALSE; oldFont.lfWeight=FW_BLACK; boldFont=CreateFontIndirect(&oldFont); } Tpreset *preset=(*parent->localPresets)[lvcd->nmcd.dwItemSpec]; if (preset->autoLoadedFromFile) { SelectObject(lvcd->nmcd.hdc,italicFont); } const char_t *defaultPreset=cfgGetStr(IDFF_defaultPreset); if (stricmp(defaultPreset,preset->presetName)==0) { SelectObject(lvcd->nmcd.hdc,boldFont); } setDlgResult(/*CDRF_NOTIFYPOSTPAINT*/CDRF_NEWFONT); return TRUE; } return TRUE; } } break; } } return TconfPageDec::msgProc(uMsg,wParam,lParam); }
INT_PTR TffdshowPageBase::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: { for (ThtiPages::const_iterator htiPage = htiPages.begin(); htiPage != htiPages.end(); htiPage++) { delete *htiPage; } htiPages.clear(); page = NULL; if (arrowsFont) { DeleteObject(arrowsFont); } arrowsFont = NULL; if (hil) { ImageList_Destroy(hil); } hil = NULL; for (int i = 0; i < countof(bmp1); i++) { DeleteObject(bmp1[i]); DeleteObject(bmp2[i]); } break; } case WM_FFONCHANGE: DPRINTF(_l("onChangeParam")); if (wParam == IDFF_alwaysOnTop && IsWindow(dlg)) { SetWindowPos(dlg, lParam ? HWND_TOPMOST : HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } if (wParam != 0) { setChange(); } return TRUE; case WM_FFONFRAME: { MSG msg; if (PeekMessage(&msg, m_hwnd, WM_FFONFRAME, WM_FFONFRAME, PM_NOREMOVE)) { return TRUE; // drop msg when next WM_FFONFRAME is already in the message queue. } for (ThtiPages::const_iterator hp = htiPages.begin(); hp != htiPages.end(); hp++) for (TconfPages::const_iterator i = (*hp)->begin(); i != (*hp)->end(); i++) if ((*i)->m_hwnd) { (*i)->onFrame(); } return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BT_HELP: if (HIWORD(wParam) == BN_CLICKED) { onHelp(); return TRUE; } break; } break; case WM_CONTEXTMENU: if (translateTV()) { return TRUE; } break; case WM_NOTIFY: { NMHDR *nmhdr = LPNMHDR(lParam); if (nmhdr->hwndFrom == htv && nmhdr->idFrom == IDC_TV_TREE) switch (nmhdr->code) { case TVN_SELCHANGED: { NMTREEVIEW *nmtv = LPNMTREEVIEW(lParam); if (nmtv->itemNew.hItem) { selectPage(hti2page(nmtv->itemNew.hItem)); return TRUE; } break; } case TVN_ITEMEXPANDING: { NMTREEVIEW *nmtv = LPNMTREEVIEW(lParam); if (nmtv->action == TVE_COLLAPSE) { setDlgResult(TRUE); } return TRUE; } } break; } } return Twindow::msgProc(uMsg, wParam, lParam); }