Ejemplo n.º 1
0
PVideoFrame AreaResize::GetFrame(int n, IScriptEnvironment* env)
{
    PVideoFrame src = child->GetFrame(n, env);
    if (params[0].src_width == params[0].target_width &&
            params[0].src_height == params[0].target_height) {
        return src;
    }

    PVideoFrame dst = env->NewVideoFrame(vi);

    int plane[] = {PLANAR_Y, PLANAR_U, PLANAR_V};
    for (int i = 0, time = vi.IsInterleaved() ? 1 : 3; i < time; i++) {
        const BYTE* srcp = src->GetReadPtr(plane[i]);
        int src_pitch = src->GetPitch(plane[i]);

        const BYTE* resized_h;
        if (params[i].src_width == params[i].target_width) {
            resized_h = srcp;
        } else {
            if (!ResizeHorizontal(buff, srcp, src_pitch, &params[i])) {
                return dst;
            }
            resized_h = buff;
            src_pitch = dst->GetRowSize(plane[i]);
        }

        BYTE* dstp = dst->GetWritePtr(plane[i]);
        int dst_pitch = dst->GetPitch(plane[i]);
        if (params[i].src_height == params[i].target_height) {
            env->BitBlt(dstp, dst_pitch, resized_h, src_pitch, dst->GetRowSize(plane[i]), dst->GetHeight(plane[i]));
            continue;
        }

        if (!ResizeVertical(dstp, dst_pitch, resized_h, src_pitch, &params[i])) {
            return dst;
        }
    }

    return dst;
}
Ejemplo n.º 2
0
INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	post_status_data *data;

	switch (message)
	{

	case WM_INITDIALOG:
	{
		TranslateDialogDefault(hwnd);

		SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(GetIconHandle("mind")));

		data = reinterpret_cast<post_status_data*>(lparam);

		SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
		SendDlgItemMessage(hwnd, IDC_MINDMSG, EM_LIMITTEXT, FACEBOOK_MIND_LIMIT, 0);
		SendDlgItemMessage(hwnd, IDC_URL, EM_LIMITTEXT, 1024, 0);

		ptrT place(data->proto->getTStringA(FACEBOOK_KEY_PLACE));
		SetDlgItemText(hwnd, IDC_PLACE, place != NULL ? place : _T("Miranda NG"));

		bShowContacts = data->proto->getByte("PostStatusExpand", 0) > 0;
		ResizeHorizontal(hwnd, bShowContacts);

		HWND hwndClist = GetDlgItem(hwnd, IDC_CCLIST);
		SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE);

		for (std::vector<wall_data*>::size_type i = 0; i < data->walls.size(); i++)
			SendDlgItemMessage(hwnd, IDC_WALL, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(data->walls[i]->title));
		SendDlgItemMessage(hwnd, IDC_WALL, CB_SETCURSEL, 0, 0);
		SendDlgItemMessage(hwnd, IDC_WALL, CB_SETCURSEL, data->proto->getByte(FACEBOOK_KEY_LAST_WALL, 0), 0);
		RefreshPrivacy(hwnd, data);

		ptrA firstname(data->proto->getStringA(FACEBOOK_KEY_FIRST_NAME));
		if (firstname != NULL) {
			char title[100];
			mir_snprintf(title, Translate("What's on your mind, %s?"), firstname);
			SetWindowTextA(hwnd, title);
		}
	}

	EnableWindow(GetDlgItem(hwnd, IDOK), FALSE);
	return TRUE;

	case WM_NOTIFY:
	{
		NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lparam;
		if (nmc->hdr.idFrom == IDC_CCLIST) {
			switch (nmc->hdr.code) {
			case CLN_LISTREBUILT:
				data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
				ClistPrepare(data->proto, NULL, nmc->hdr.hwndFrom);
				break;
			}
		}
	}
	break;

	case WM_COMMAND:
		switch (LOWORD(wparam))
		{
		case IDC_WALL:
			if (HIWORD(wparam) == CBN_SELCHANGE) {
				data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
				RefreshPrivacy(hwnd, data);
			}
			break;

		case IDC_MINDMSG:
		case IDC_URL:
			if (HIWORD(wparam) == EN_CHANGE) {
				bool ok = SendDlgItemMessage(hwnd, IDC_MINDMSG, WM_GETTEXTLENGTH, 0, 0) > 0;
				if (!ok && SendDlgItemMessage(hwnd, IDC_URL, WM_GETTEXTLENGTH, 0, 0) > 0)
					ok = true;

				EnableWindow(GetDlgItem(hwnd, IDOK), ok);
				return TRUE;
			}
			break;

		case IDC_EXPAND:
			bShowContacts = !bShowContacts;
			ResizeHorizontal(hwnd, bShowContacts);
			break;

		case IDOK:
		{
			data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));

			TCHAR mindMessageT[FACEBOOK_MIND_LIMIT + 1];
			TCHAR urlT[1024];
			TCHAR placeT[100];

			GetDlgItemText(hwnd, IDC_MINDMSG, mindMessageT, _countof(mindMessageT));
			GetDlgItemText(hwnd, IDC_PLACE, placeT, _countof(placeT));
			GetDlgItemText(hwnd, IDC_URL, urlT, _countof(urlT));
			ShowWindow(hwnd, SW_HIDE);

			int wall_id = SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCURSEL, 0, 0);
			int privacy_id = SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0);

			data->proto->setTString(FACEBOOK_KEY_PLACE, placeT);
			data->proto->setByte("PostStatusExpand", bShowContacts);

			// remember last wall, only when there are more options
			if (SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCOUNT, 0, 0) > 1)
				data->proto->setByte(FACEBOOK_KEY_LAST_WALL, wall_id);

			// remember last privacy, only when there are more options
			if (SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCOUNT, 0, 0) > 1)
				data->proto->setByte(FACEBOOK_KEY_PRIVACY_TYPE, privacy_id);

			status_data *status = new status_data();
			status->user_id = data->walls[wall_id]->user_id;
			status->isPage = data->walls[wall_id]->isPage;
			status->privacy = privacy_types[privacy_id].id;
			status->place = T2Utf(placeT);
			status->url = _T2A(urlT);

			HWND hwndList = GetDlgItem(hwnd, IDC_CCLIST);
			GetSelectedContacts(data->proto, NULL, hwndList, &status->users);

			T2Utf narrow(mindMessageT);
			status->text = narrow;

			if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char*)narrow)
				data->proto->last_status_msg_ = narrow;

			data->proto->ForkThread(&FacebookProto::SetAwayMsgWorker, status);

			EndDialog(hwnd, wparam);
			return TRUE;
		}

		case IDCANCEL:
			EndDialog(hwnd, wparam);
			return TRUE;

		} break;
	case WM_DESTROY:
		data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));

		for (std::vector<wall_data*>::size_type i = 0; i < data->walls.size(); i++) {
			mir_free(data->walls[i]->title);
			delete data->walls[i];
		}

		delete data;
	}

	return FALSE;
}