static void getNonClientMetrics(NONCLIENTMETRICS* metrics)
{
    static UINT size = (windowsVersion() >= WindowsVista) ?
        (sizeof NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA;
    metrics->cbSize = size;
    bool success = !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, size, metrics, 0);
    ASSERT(success);
}
ImeModule::ImeModule(HMODULE module):
	Ime::ImeModule(module, g_textServiceClsid),
	config_(windowsVersion()) {
	
	config_.load(); // load configurations

	// override default location of chewing data directories
	std::wstring env;
	wchar_t path[MAX_PATH];

	HRESULT result;

	// get user profile directory
	if(::GetEnvironmentVariableW(L"USERPROFILE", path, MAX_PATH)) {
		userDir_ = path;
		userDir_ += L"\\ChewingTextService";
		// create the user directory if not exists
		// NOTE: this call will fail in Windows 8 store apps
		// We need a way to create the dir in desktop mode and
		// set proper ACL, so later we can access it inside apps.
		DWORD attributes = ::GetFileAttributesW(userDir_.c_str());
		if(attributes == INVALID_FILE_ATTRIBUTES) {
			// create the directory if it does not exist
			if(::GetLastError() == ERROR_FILE_NOT_FOUND) {
				::CreateDirectoryW(userDir_.c_str(), NULL);
				attributes = ::GetFileAttributesW(userDir_.c_str());
			}
		}

		// make the directory hidden
		if(attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_HIDDEN) == 0)
			::SetFileAttributesW(userDir_.c_str(), attributes|FILE_ATTRIBUTE_HIDDEN);

		env = L"CHEWING_USER_PATH=";
		env += userDir_;
		_wputenv(env.c_str());
	}

	// get the program data directory
	// try C:\program files (x86) first
	result = ::SHGetFolderPathW(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
	if(result != S_OK) // failed, fall back to C:\program files
		result = ::SHGetFolderPathW(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
	if(result == S_OK) { // program files folder is found
		programDir_ = path;
		programDir_ += L"\\ChewingTextService";
		env = L"CHEWING_PATH=";
		// prepend user dir path to program path, so user-specific files, if they exist,
		// can take precedence over built-in ones. (for ex: symbols.dat)
		env += userDir_;
		env += ';'; // add ; to separate two dir paths
		// add program dir after user profile dir
		env += programDir_;
		env += L"\\Dictionary";
		_wputenv(env.c_str());
	}

}
Esempio n. 3
0
int ScrollbarThemeChromiumWin::getThemeState(ScrollbarThemeClient* scrollbar, ScrollbarPart part) const
{
    // When dragging the thumb, draw thumb pressed and other segments normal
    // regardless of where the cursor actually is.  See also four places in
    // getThemeArrowState().
    if (scrollbar->pressedPart() == ThumbPart) {
        if (part == ThumbPart)
            return SCRBS_PRESSED;
        return (windowsVersion() < WindowsVista) ? SCRBS_NORMAL : SCRBS_HOVER;
    }
    if (!scrollbar->enabled())
        return SCRBS_DISABLED;
    if (scrollbar->hoveredPart() != part || part == BackTrackPart || part == ForwardTrackPart)
        return (scrollbar->hoveredPart() == NoPart || (windowsVersion() < WindowsVista)) ? SCRBS_NORMAL : SCRBS_HOVER;
    if (scrollbar->pressedPart() == NoPart)
        return SCRBS_HOT;
    return (scrollbar->pressedPart() == part) ? SCRBS_PRESSED : SCRBS_NORMAL;
}
Esempio n. 4
0
String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
{
   DEFINE_STATIC_LOCAL(String, osVersion, (windowsVersion()));
   DEFINE_STATIC_LOCAL(String, webKitVersion, (userVisibleWebKitVersionString()));

   // FIXME: We should upate the user agent if the default language changes.
   String language = defaultLanguage();

   if (applicationNameForUserAgent.isEmpty())
       return makeString("Mozilla/5.0 (Windows; U; ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)");
   return makeString("Mozilla/5.0 (Windows; U; ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) ", applicationNameForUserAgent);
}
Esempio n. 5
0
int ScrollbarThemeChromiumWin::getThemeArrowState(ScrollbarThemeClient* scrollbar, ScrollbarPart part) const
{
    // We could take advantage of knowing the values in the state enum to write
    // some simpler code, but treating the state enum as a black box seems
    // clearer and more future-proof.
    if (part == BackButtonStartPart || part == ForwardButtonStartPart) {
        if (scrollbar->orientation() == HorizontalScrollbar) {
            if (scrollbar->pressedPart() == ThumbPart)
                return (windowsVersion() < WindowsVista) ? ABS_LEFTNORMAL : ABS_LEFTHOVER;
            if (!scrollbar->enabled())
                return ABS_LEFTDISABLED;
            if (scrollbar->hoveredPart() != part)
                return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_LEFTNORMAL : ABS_LEFTHOVER;
            if (scrollbar->pressedPart() == NoPart)
                return ABS_LEFTHOT;
            return (scrollbar->pressedPart() == part) ?
                ABS_LEFTPRESSED : ABS_LEFTNORMAL;
        }
        if (scrollbar->pressedPart() == ThumbPart)
            return (windowsVersion() < WindowsVista) ? ABS_UPNORMAL : ABS_UPHOVER;
        if (!scrollbar->enabled())
            return ABS_UPDISABLED;
        if (scrollbar->hoveredPart() != part)
            return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_UPNORMAL : ABS_UPHOVER;
        if (scrollbar->pressedPart() == NoPart)
            return ABS_UPHOT;
        return (scrollbar->pressedPart() == part) ? ABS_UPPRESSED : ABS_UPNORMAL;
    }
    if (scrollbar->orientation() == HorizontalScrollbar) {
        if (scrollbar->pressedPart() == ThumbPart)
            return (windowsVersion() < WindowsVista) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER;
        if (!scrollbar->enabled())
            return ABS_RIGHTDISABLED;
        if (scrollbar->hoveredPart() != part)
            return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER;
        if (scrollbar->pressedPart() == NoPart)
            return ABS_RIGHTHOT;
        return (scrollbar->pressedPart() == part) ? ABS_RIGHTPRESSED : ABS_RIGHTNORMAL;
    }
    if (scrollbar->pressedPart() == ThumbPart)
        return (windowsVersion() < WindowsVista) ? ABS_DOWNNORMAL : ABS_DOWNHOVER;
    if (!scrollbar->enabled())
        return ABS_DOWNDISABLED;
    if (scrollbar->hoveredPart() != part)
        return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_DOWNNORMAL : ABS_DOWNHOVER;
    if (scrollbar->pressedPart() == NoPart)
        return ABS_DOWNHOT;
    return (scrollbar->pressedPart() == part) ? ABS_DOWNPRESSED : ABS_DOWNNORMAL;
}
Esempio n. 6
0
QString djvSystem::info()
{
    QString out;

#if defined(DJV_WINDOWS)

    out = windowsLabels()[windowsVersion()];

#else // DJV_WINDOWS

    ::utsname info;
    uname(&info);

    out = QString("%1 %2 %3").
        arg(info.sysname).
        arg(info.release).
        arg(info.machine);

#endif // DJV_WINDOWS

    return out;
}
Esempio n. 7
0
bool ScrollbarThemeChromiumWin::invalidateOnMouseEnterExit()
{
    return windowsVersion() >= WindowsVista;
}
Esempio n. 8
0
static PassRefPtr<SharedCursor> createSharedCursor(Image* img, const IntPoint& hotSpot)
{
    RefPtr<SharedCursor> impl;

    IntPoint effectiveHotSpot = determineHotSpot(img, hotSpot);
    static bool doAlpha = windowsVersion() >= WindowsXP;
    BitmapInfo cursorImage = BitmapInfo::create(IntSize(img->width(), img->height()));

    HWndDC dc(0);
    auto workingDC = adoptGDIObject(::CreateCompatibleDC(dc));
    if (doAlpha) {
        auto hCursor = adoptGDIObject(::CreateDIBSection(dc, (BITMAPINFO *)&cursorImage, DIB_RGB_COLORS, 0, 0, 0));
        ASSERT(hCursor);

        img->getHBITMAP(hCursor.get()); 
        HBITMAP hOldBitmap = (HBITMAP)SelectObject(workingDC.get(), hCursor.get());
        SetBkMode(workingDC.get(), TRANSPARENT);
        SelectObject(workingDC.get(), hOldBitmap);

        Vector<unsigned char, 128> maskBits;
        maskBits.fill(0xff, (img->width() + 7) / 8 * img->height());
        auto hMask = adoptGDIObject(::CreateBitmap(img->width(), img->height(), 1, 1, maskBits.data()));

        ICONINFO ii;
        ii.fIcon = FALSE;
        ii.xHotspot = effectiveHotSpot.x();
        ii.yHotspot = effectiveHotSpot.y();
        ii.hbmMask = hMask.get();
        ii.hbmColor = hCursor.get();

        impl = SharedCursor::create(::CreateIconIndirect(&ii));
    } else {
        // Platform doesn't support alpha blended cursors, so we need
        // to create the mask manually
        auto andMaskDC = adoptGDIObject(::CreateCompatibleDC(dc));
        auto xorMaskDC = adoptGDIObject(::CreateCompatibleDC(dc));
        auto hCursor = adoptGDIObject(::CreateDIBSection(dc, &cursorImage, DIB_RGB_COLORS, 0, 0, 0));
        ASSERT(hCursor);
        img->getHBITMAP(hCursor.get()); 
        BITMAP cursor;
        GetObject(hCursor.get(), sizeof(BITMAP), &cursor);
        auto andMask = adoptGDIObject(::CreateBitmap(cursor.bmWidth, cursor.bmHeight, 1, 1, 0));
        auto xorMask = adoptGDIObject(::CreateCompatibleBitmap(dc, cursor.bmWidth, cursor.bmHeight));
        HBITMAP oldCursor = (HBITMAP)SelectObject(workingDC.get(), hCursor.get());
        HBITMAP oldAndMask = (HBITMAP)SelectObject(andMaskDC.get(), andMask.get());
        HBITMAP oldXorMask = (HBITMAP)SelectObject(xorMaskDC.get(), xorMask.get());

        SetBkColor(workingDC.get(), RGB(0, 0, 0));  
        BitBlt(andMaskDC.get(), 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC.get(), 0, 0, SRCCOPY);
    
        SetBkColor(xorMaskDC.get(), RGB(255, 255, 255));
        SetTextColor(xorMaskDC.get(), RGB(255, 255, 255));
        BitBlt(xorMaskDC.get(), 0, 0, cursor.bmWidth, cursor.bmHeight, andMaskDC.get(), 0, 0, SRCCOPY);
        BitBlt(xorMaskDC.get(), 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC.get(), 0, 0, SRCAND);

        SelectObject(workingDC.get(), oldCursor);
        SelectObject(andMaskDC.get(), oldAndMask);
        SelectObject(xorMaskDC.get(), oldXorMask);

        ICONINFO icon = {0};
        icon.fIcon = FALSE;
        icon.xHotspot = effectiveHotSpot.x();
        icon.yHotspot = effectiveHotSpot.y();
        icon.hbmMask = andMask.get();
        icon.hbmColor = xorMask.get();
        impl = SharedCursor::create(CreateIconIndirect(&icon));
    }

    return impl.release();
}