Exemplo n.º 1
0
 TestFontProperty(CanvasFontPropertyIdentifier id, wchar_t const* value, wchar_t const* locale)
     : Locale(locale)
     , Value(value)
 {
     Win2DProperty.Identifier = id;
     Win2DProperty.Locale = Locale;
     Win2DProperty.Value = Value;
     DWriteProperty.propertyId = static_cast<DWRITE_FONT_PROPERTY_ID>(id);
     DWriteProperty.localeName = WindowsGetStringRawBuffer(Locale, nullptr);
     DWriteProperty.propertyValue = WindowsGetStringRawBuffer(Value, nullptr);
 }
    IFACEMETHODIMP DrawUnderline(
        Vector2 baselineOrigin,
        float width,
        float thickness,
        float offset,
        float runHeight,
        CanvasTextDirection textDirection,
        IInspectable* brush,
        CanvasTextMeasuringMode measuringMode,
        HSTRING locale,
        CanvasGlyphOrientation glyphOrientation)
    {
        return ExceptionBoundary(
            [&]
            {
                EnsureValidResource();

                DWRITE_UNDERLINE underline{};
                underline.width = width;
                underline.thickness = thickness;
                underline.offset = offset;
                underline.runHeight = runHeight;

                auto textDirectionLookup = DWriteToCanvasTextDirection::Lookup(textDirection);
                underline.flowDirection = textDirectionLookup->FlowDirection;
                underline.readingDirection = textDirectionLookup->ReadingDirection;
                underline.measuringMode = ToDWriteMeasuringMode(measuringMode);

                auto deviceContextLease = As<ICanvasDeviceInternal>(m_device)->GetResourceCreationDeviceContext();

                if (locale)
                    underline.localeName = WindowsGetStringRawBuffer(locale, nullptr);

                ThrowIfFailed(m_dwriteTextRenderer->DrawUnderline(
                    nullptr,
                    baselineOrigin.X,
                    baselineOrigin.Y,
                    ToDWriteGlyphOrientationAngle(glyphOrientation),
                    &underline,
                    DrawGlyphRunHelper::GetClientDrawingEffect(brush, deviceContextLease.Get()).Get()));
            });
    }
Exemplo n.º 3
0
    static uint32_t ToTrimmingDelimiter(WinString const& value)
    {
        // TODO #1658: Do the unicode conversion properly.
        // http://www.unicode.org/faq/utf_bom.html#utf16-3.  This code needs its
        // own set of tests.

        uint32_t sourceStringLength = 0;
        auto sourceString = WindowsGetStringRawBuffer(value, &sourceStringLength);

        if (sourceStringLength == 0)
        {
            return 0;
        }
        else if (sourceStringLength == 1)
        {
            return sourceString[0];
        }
        else
        {
            return (sourceString[0] << 16) | sourceString[1];
        }
    }
Exemplo n.º 4
0
 void AssertStringsEqual(HSTRING a, HSTRING b)
 {
     std::wstring s1 = WindowsGetStringRawBuffer(a, nullptr);
     std::wstring s2 = WindowsGetStringRawBuffer(b, nullptr);
     Assert::AreEqual(s1, s2);
 }
Exemplo n.º 5
0
Arquivo: dirs.c Projeto: tguillem/vlc
static HRESULT WinRTSHGetFolderPath(HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
{
    VLC_UNUSED(hwnd);
    VLC_UNUSED(hToken);

    HRESULT hr;
    IStorageFolder *folder;

    if (dwFlags != SHGFP_TYPE_CURRENT)
        return E_NOTIMPL;

    folder = NULL;
    csidl &= ~0xFF00; /* CSIDL_FLAG_MASK */

    if (csidl == CSIDL_APPDATA) {
        IApplicationDataStatics *appDataStatics = NULL;
        IApplicationData *appData = NULL;
        static const WCHAR *className = L"Windows.Storage.ApplicationData";
        const UINT32 clen = wcslen(className);

        HSTRING hClassName = NULL;
        HSTRING_HEADER header;
        hr = WindowsCreateStringReference(className, clen, &header, &hClassName);
        if (FAILED(hr))
            goto end_appdata;

        hr = RoGetActivationFactory(hClassName, &IID_IApplicationDataStatics, (void**)&appDataStatics);

        if (FAILED(hr))
            goto end_appdata;

        if (!appDataStatics) {
            hr = E_FAIL;
            goto end_appdata;
        }

        hr = IApplicationDataStatics_get_Current(appDataStatics, &appData);

        if (FAILED(hr))
            goto end_appdata;

        if (!appData) {
            hr = E_FAIL;
            goto end_appdata;
        }

        hr = IApplicationData_get_LocalFolder(appData, &folder);

end_appdata:
        WindowsDeleteString(hClassName);
        if (appDataStatics)
            IApplicationDataStatics_Release(appDataStatics);
        if (appData)
            IApplicationData_Release(appData);
    }
    else
    {
        IKnownFoldersStatics *knownFoldersStatics = NULL;
        static const WCHAR *className = L"Windows.Storage.KnownFolders";
        const UINT32 clen = wcslen(className);

        HSTRING hClassName = NULL;
        HSTRING_HEADER header;
        hr = WindowsCreateStringReference(className, clen, &header, &hClassName);
        if (FAILED(hr))
            goto end_other;

        hr = RoGetActivationFactory(hClassName, &IID_IKnownFoldersStatics, (void**)&knownFoldersStatics);

        if (FAILED(hr))
            goto end_other;

        if (!knownFoldersStatics) {
            hr = E_FAIL;
            goto end_other;
        }

        switch (csidl) {
        case CSIDL_PERSONAL:
            hr = IKnownFoldersStatics_get_DocumentsLibrary(knownFoldersStatics, &folder);
            break;
        case CSIDL_MYMUSIC:
            hr = IKnownFoldersStatics_get_MusicLibrary(knownFoldersStatics, &folder);
            break;
        case CSIDL_MYPICTURES:
            hr = IKnownFoldersStatics_get_PicturesLibrary(knownFoldersStatics, &folder);
            break;
        case CSIDL_MYVIDEO:
            hr = IKnownFoldersStatics_get_VideosLibrary(knownFoldersStatics, &folder);
            break;
        default:
            hr = E_NOTIMPL;
        }

end_other:
        WindowsDeleteString(hClassName);
        if (knownFoldersStatics)
            IKnownFoldersStatics_Release(knownFoldersStatics);
    }

    if( SUCCEEDED(hr) && folder != NULL )
    {
        HSTRING path = NULL;
        IStorageItem *item = NULL;
        PCWSTR pszPathTemp;
        hr = IStorageFolder_QueryInterface(folder, &IID_IStorageItem, (void**)&item);
        if (FAILED(hr))
            goto end_folder;
        hr = IStorageItem_get_Path(item, &path);
        if (FAILED(hr))
            goto end_folder;
        pszPathTemp = WindowsGetStringRawBuffer(path, NULL);
        wcscpy(pszPath, pszPathTemp);
end_folder:
        WindowsDeleteString(path);
        IStorageFolder_Release(folder);
        if (item)
            IStorageItem_Release(item);
    }

    return hr;
}