Пример #1
0
INT_PTR TgenericPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_NOTIFY: {
            NMHDR *nmhdr=LPNMHDR(lParam);
            if (!nostate && nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_GENERIC)
                switch (nmhdr->code) {
                    case LVN_ITEMCHANGED: {
                        LPNMLISTVIEW nmlv=LPNMLISTVIEW(lParam);
                        if (nmlv->uChanged&LVIF_STATE && ((nmlv->uOldState&4096)!=(nmlv->uNewState&4096))) {
                            Tflag *f=(Tflag*)nmlv->lParam;
                            if (nmlv->uNewState&8192) {
                                cfgSet(std::get<IDFF-1>(*f),cfgGet(std::get<IDFF-1>(*f))|std::get<VAL-1>(*f));
                            } else if (nmlv->uNewState&4096) {
                                cfgSet(std::get<IDFF-1>(*f),cfgGet(std::get<IDFF-1>(*f))&~std::get<VAL-1>(*f));
                            }
                            if (std::get<REPAINT-1>(*f)) {
                                cfg2dlg();
                            }
                        }
                        return TRUE;
                    }
                    break;
                }
            break;
        }
    }
    return TconfPageEnc::msgProc(uMsg,wParam,lParam);
}
Пример #2
0
INT_PTR TOSDpageDec::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDC_CHB_OSD:
                    cfgSet(IDFF_isOSD, getCheck(IDC_CHB_OSD));
                    parent->drawInter();
                    return TRUE;
                case IDC_CHB_OSD_IS_AUTO_HIDE:
                    cfgSet(IDFF_OSDisAutoHide, getCheck(IDC_CHB_OSD_IS_AUTO_HIDE));
                    osd2dlg();
                    parent->setChange();
                    break;
                case IDC_ED_OSD_DURATION_VISIBLE:
                    if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) {
                        HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam));
                        if (hed != GetFocus()) {
                            return FALSE;
                        }
                        repaint(hed);
                        parent->setChange();
                        break;
                    }
                    break;
                case IDC_CHB_OSD_USER:
                    if (!getCheck(IDC_CHB_OSD_USER)) {
                        lv2osdFormat();
                    } else {
                        cfgSet(IDFF_OSDformat, _l("user"));
                    }
                    osd2dlg();
                    parent->setChange();
                    break;
                case IDC_ED_OSD_USER:
                    if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) {
                        char_t ed[1020]; //4 chars are reserved for "user" prefix
                        GetDlgItemText(m_hwnd, IDC_ED_OSD_USER, ed, 1020);
                        char_t format[1024];
                        tsnprintf_s(format, 1024, _TRUNCATE, _l("user%s"), ed);
                        cfgSet(IDFF_OSDformat, format);
                        parent->setChange();
                    };
                    break;
                case IDC_ED_OSD_SAVE:
                    if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) {
                        char_t saveflnm[MAX_PATH];
                        GetDlgItemText(m_hwnd, IDC_ED_OSD_SAVE, saveflnm, MAX_PATH);
                        cfgSet(IDFF_OSDsaveFlnm, saveflnm);
                        return TRUE;
                    }
                    return TRUE;
            }
            break;
        case WM_NOTIFY: {
            NMHDR *nmhdr = LPNMHDR(lParam);
            if (!nostate && nmhdr->hwndFrom == hlv && nmhdr->idFrom == IDC_LV_OSD_LINES)
                switch (nmhdr->code) {
                    case LVN_ITEMCHANGED: {
                        LPNMLISTVIEW nmlv = LPNMLISTVIEW(lParam);
                        if (nmlv->uChanged & LVIF_STATE && ((nmlv->uOldState & 4096) != (nmlv->uNewState & 4096))) {
                            lv2osdFormat();
                        }
                        return TRUE;
                    }
                    case LVN_BEGINDRAG: {
                        if (!user) {
                            LPNMLISTVIEW nmlv = LPNMLISTVIEW(lParam);
                            if (nmlv->iItem != -1) {
                                dragitem = nmlv->iItem;
                                SetCapture(m_hwnd);
                            }
                        }
                        break;
                    }
                    case NM_DBLCLK: {
                        if (user) {
                            LPNMITEMACTIVATE nmia = LPNMITEMACTIVATE(lParam);
                            if (nmia->iItem != -1) {
                                const char_t *shortcut = deci->getInfoItemShortcut((int)lvGetItemParam(IDC_LV_OSD_LINES, nmia->iItem));
                                if (shortcut && shortcut[0]) {
                                    char_t osd[1020];
                                    tsnprintf_s(osd, countof(osd), _TRUNCATE, _l("%%%s"), shortcut);
                                    SendDlgItemMessage(m_hwnd, IDC_ED_OSD_USER, EM_REPLACESEL, TRUE, LPARAM(osd));
                                }
                            }
                        }
                        break;
                    }
                }
            break;
        }
        case WM_MOUSEMOVE:
            if (dragitem != -1) {
                LVHITTESTINFO lvhti;
                lvhti.pt.x = LOWORD(lParam) - lvx;
                lvhti.pt.y = HIWORD(lParam) - lvy;
                int target = ListView_HitTest(hlv, &lvhti);
                if (target != -1) {
                    lvSwapItems(IDC_LV_OSD_LINES, target, dragitem);
                    lv2osdFormat();
                    dragitem = target;
                }
                return TRUE;
            }
            break;
        case WM_LBUTTONUP:
            if (dragitem != -1) {
                dragitem = -1;
                ReleaseCapture();
                return TRUE;
            }
            break;
    }
    return TconfPageDec::msgProc(uMsg, wParam, lParam);
}
Пример #3
0
INT_PTR TconvolverPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_DESTROY:
            cfgSet(IDFF_lvConvolverWidth0,ListView_GetColumnWidth(hlv,0));
            cfgSet(IDFF_lvConvolverWidth1,ListView_GetColumnWidth(hlv,1));
            cfgSet(IDFF_lvConvolverWidth2,ListView_GetColumnWidth(hlv,2));
            cfgSet(IDFF_lvConvolverSelected,lvGetSelItem(IDC_LV_CONVOLVER_FILES));
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDC_ED_CONVOLVER_FILE:
                    if (HIWORD(wParam)==EN_CHANGE && !isSetWindowText) {
                        char_t flnm[MAX_PATH];
                        GetDlgItemText(m_hwnd,IDC_ED_CONVOLVER_FILE,flnm,MAX_PATH);
                        cfgSet(IDFF_convolverFile,flnm);
                        format2dlg(flnm);
                    }
                    return TRUE;
            }
            break;
        case WM_NOTIFY: {
            NMHDR *nmhdr=LPNMHDR(lParam);
            if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_CONVOLVER_FILES)
                switch (nmhdr->code) {
                    case LVN_ITEMCHANGED: {
                        NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam);
                        enableMapping(nmlv->iItem!=-1);
                        return TRUE;
                    }
                    case NM_DBLCLK: {
                        NMITEMACTIVATE *nmia=(NMITEMACTIVATE*)lParam;
                        if (nmia->iItem==-1 || nmia->iSubItem!=1) {
                            return FALSE;
                        }
                        onManualFileSet();
                        return TRUE;
                    }
                    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: {
                                    static const int speakers[]= {SPEAKER_FRONT_LEFT,SPEAKER_FRONT_RIGHT,SPEAKER_FRONT_CENTER,SPEAKER_LOW_FREQUENCY,SPEAKER_BACK_LEFT,SPEAKER_BACK_RIGHT};
                                    strcpy(nmdi->item.pszText,_(IDC_LV_CONVOLVER_FILES,TsampleFormat::getSpeakerName(speakers[i])));
                                    break;
                                }
                                case 1: {
                                    int dx=ListView_GetColumnWidth(hlv,1);
                                    char_t flnm[MAX_PATH];
                                    cfgGet(speakersIdffs[i],flnm,MAX_PATH);
                                    HDC dc=GetDC(hlv);
                                    HGDIOBJ old=SelectObject(dc,(HGDIOBJ)SendMessage(hlv,WM_GETFONT,0,0));
                                    PathCompactPath(dc,flnm,std::max(20,dx-15));
                                    SelectObject(dc,old);
                                    ReleaseDC(hlv,dc);
                                    strcpy(nmdi->item.pszText,flnm);
                                    break;
                                }
                                case 2:
                                    if (const char_t *flnm=cfgGetStr(speakersIdffs[i]))
                                        if (flnm[0] && !speakerFormats[i]) {
                                            speakerFormats[i]=getWavDesc(flnm,IDC_LV_CONVOLVER_FILES);
                                        }
                                    strcpy(nmdi->item.pszText,speakerFormats[i].c_str());
                                    break;
                            }
                        return TRUE;
                    }
                }
            break;
        }
    }
    return TconfPageDecAudio::msgProc(uMsg,wParam,lParam);
}
Пример #4
0
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);
}
Пример #5
0
INT_PTR TcodecsPage::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_DESTROY:
            cfgSet(IDFF_lvCodecsWidth0,ListView_GetColumnWidth(hlv,0));
            cfgSet(IDFF_lvCodecsWidth1,ListView_GetColumnWidth(hlv,1));
            cfgSet(IDFF_lvCodecsWidth2,ListView_GetColumnWidth(hlv,2));
            cfgSet(IDFF_lvCodecsSelected,lvGetSelItem(IDC_LV_INCODECS));
            break;
        case WM_COMMAND:
            switch (LOWORD(wParam)) {
                case IDC_CBX_INCODECS:
                    if (HIWORD(wParam)==CBN_SELCHANGE && IsWindowVisible(hcbx)) {
                        int ii=lvGetSelItem(IDC_LV_INCODECS);
                        int idff=formats[ii].idff;
                        cfgSet(idff,(int)cbxGetCurItemData(IDC_CBX_INCODECS));
                        options2dlg(ii);
                        return TRUE;
                    }
                    break;
                case IDC_CHB_CODEC_OPT1:
                case IDC_CHB_CODEC_OPT2:
                case IDC_CHB_CODEC_OPT3:
                case IDC_CHB_CODEC_OPT4:
                    dlg2options(LOWORD(wParam));
                    return TRUE;
            }
            break;
        case WM_NOTIFY: {
            NMHDR *nmhdr=LPNMHDR(lParam);
            if (nmhdr->hwndFrom==hlv && nmhdr->idFrom==IDC_LV_INCODECS)
                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,_(IDC_LV_INCODECS,formats[i].descr));
                                    break;
                                case 1:
                                    strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].getDecoderName(cfgGet(formats[i].idff))));
                                    break;
                                case 2:
                                    strcpy(nmdi->item.pszText,_(IDC_LV_INCODECS,formats[i].hint));
                                    break;
                            }
                        return TRUE;
                    }
                    case LVN_GETINFOTIP: {
                        NMLVGETINFOTIP *nmit=(NMLVGETINFOTIP*)lParam;
                        if (nmit->iItem!=-1 && nmit->iSubItem==0) {
                            ff_strncpy(nmit->pszText,formats[nmit->iItem].hint,nmit->cchTextMax);
                        }
                        return TRUE;
                    }
                    case LVN_ITEMCHANGED: {
                        NMLISTVIEW *nmlv=LPNMLISTVIEW(lParam);
                        if (nmlv->iItem!=curitem) {
                            curitem=-1;
                            show(false,IDC_CBX_INCODECS);
                            options2dlg(nmlv->iItem);
                        }
                        return TRUE;
                    }
                    case NM_CLICK: {
                        NMITEMACTIVATE *nmia=LPNMITEMACTIVATE(lParam);
                        if (nmia->iItem!=-1 && nmia->iSubItem==1) {
                            beginCodecChange(nmia->iItem);
                        } else {
                            show(false,IDC_CBX_INCODECS);
                        }
                        return TRUE;
                    }
                }
            break;
        }
    }
    return TconfPageBase::msgProc(uMsg,wParam,lParam);
}