예제 #1
0
VOID NcAreaInitializeTheme(
    _Inout_ PEDIT_CONTEXT Context
    )
{
    Context->CXWidth = PhMultiplyDivide(20, PhGlobalDpi, 96);
    Context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
    Context->BrushHot = CreateSolidBrush(RGB(205, 232, 255));
    Context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));

    if (IsThemeActive())
    {
        HTHEME themeDataHandle;

        if (themeDataHandle = OpenThemeData(Context->WindowHandle, VSCLASS_EDIT))
        {
            //IsThemePartDefined_I(themeDataHandle, EP_EDITBORDER_NOSCROLL, EPSHV_NORMAL);

            GetThemeInt(
                themeDataHandle,
                EP_EDITBORDER_NOSCROLL,
                EPSHV_NORMAL,
                TMT_BORDERSIZE,
                &Context->CXBorder
                );

            CloseThemeData(themeDataHandle);
        }
    }
    else
    {
        Context->CXBorder = GetSystemMetrics(SM_CXBORDER) * 2;
    }
}
예제 #2
0
파일: progress.c 프로젝트: howard5888/wineT
/* Helper to obtain gap between progress bar chunks */
static inline int get_led_gap ( PROGRESS_INFO *infoPtr )
{
    HTHEME theme = GetWindowTheme (infoPtr->Self);
    if (theme)
    {
        int spaceSize;
        if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSSPACESIZE, &spaceSize )))
            return spaceSize;
    }

    return LED_GAP;
}
예제 #3
0
파일: progress.c 프로젝트: howard5888/wineT
/* Helper to obtain size of a progress bar chunk ("led"). */
static inline int get_led_size ( PROGRESS_INFO *infoPtr, LONG style,
                                 const RECT* rect )
{
    HTHEME theme = GetWindowTheme (infoPtr->Self);
    if (theme)
    {
        int chunkSize;
        if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSCHUNKSIZE, &chunkSize )))
            return chunkSize;
    }

    if (style & PBS_VERTICAL)
        return MulDiv (rect->right - rect->left, 2, 3);
    else
        return MulDiv (rect->bottom - rect->top, 2, 3);
}
예제 #4
0
VOID PhpSearchInitializeTheme(
    _Inout_ PEDIT_CONTEXT Context
    )
{
    Context->CXWidth = PH_SCALE_DPI(20);
    Context->BrushNormal = GetSysColorBrush(COLOR_WINDOW);
    Context->BrushHot = CreateSolidBrush(RGB(205, 232, 255));
    Context->BrushPushed = CreateSolidBrush(RGB(153, 209, 255));

    if (IsThemeActive())
    {
        HTHEME themeDataHandle;

        if (themeDataHandle = OpenThemeData(Context->WindowHandle, VSCLASS_EDIT))
        {
            //IsThemePartDefined_I(themeDataHandle, EP_EDITBORDER_NOSCROLL, EPSHV_NORMAL);

            if (!SUCCEEDED(GetThemeInt(
                themeDataHandle,
                EP_EDITBORDER_NOSCROLL,
                EPSHV_NORMAL,
                TMT_BORDERSIZE,
                &Context->CXBorder
                )))
            {
                Context->CXBorder = GetSystemMetrics(SM_CXBORDER) * 2;
            }

            CloseThemeData(themeDataHandle);
        }
        else
        {
            Context->CXBorder = GetSystemMetrics(SM_CXBORDER) * 2;
        }
    }
    else
    {
        Context->CXBorder = GetSystemMetrics(SM_CXBORDER) * 2;
    }
}
예제 #5
0
BOOL AeroControlBase::DetermineGlowSize(int *piSize, LPCWSTR pszClassIdList /*= NULL*/)
{
    if (!piSize)
    {
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (!pszClassIdList)
        pszClassIdList = L"CompositedWindow::Window";

    HTHEME hThemeWindow = OpenThemeData(NULL, pszClassIdList);
    if (hThemeWindow != NULL)
    {
        VERIFY(SUCCEEDED(GetThemeInt(hThemeWindow, 0, 0, TMT_TEXTGLOWSIZE, piSize)));
        VERIFY(SUCCEEDED(CloseThemeData(hThemeWindow)));
        return TRUE;
    }

    SetLastError(ERROR_FILE_NOT_FOUND);
    return FALSE;
}
예제 #6
0
int main(int argc, char** argv)
{
        argc_main = argc;
        argv_main = argv;
	SplashColor paperColor;
	GooString* filename, *password;
	char* spwd;
	FILE* f = NULL;
	bookinfo* bi;
	char buf[1024];
	int i;

	mkdir(CACHEDIR, 0777);
	chmod(CACHEDIR, 0777);

	spwd = GetDeviceKey();

	if (setgid(102) != 0) fprintf(stderr, "warning: cannot set gid\n");
	if (setuid(102) != 0) fprintf(stderr, "warning: cannot set uid\n");

	if (spwd)
	{
		//fprintf(stderr, "password: %s\n", spwd);
		password = new GooString(spwd);
	}
	else
	{
		fprintf(stderr, "warning: cannot read password\n");
		password = NULL;
	}

	OpenScreen();

	signal(SIGFPE, sigfpe_handler);
	signal(SIGSEGV, sigsegv_handler);

	clock_left = GetThemeInt("panel.clockleft", 0);
	bmk_flag = GetResource("bmk_flag", NULL);

	if (argc < 2)
	{
		Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
		return 0;
	}

	OriginalName = FileName = argv[1];
	bi = GetBookInfo(FileName);
	if (bi->title) book_title = strdup(bi->title);

	// read config file
	globalParams = new GlobalParams();

	globalParams->setEnableFreeType("yes");
	globalParams->setAntialias((char*)(ivstate.antialiasing ? "yes" : "no"));
	globalParams->setVectorAntialias("no");

	filename = new GooString(FileName);
	doc = new PDFDoc(filename, NULL, NULL);
	if (!doc->isOk())
	{
		int err = doc->getErrorCode();
		delete doc;
		if (err == 4)   // encrypted file
		{
			filename = new GooString(FileName);
			doc = new PDFDoc(filename, NULL, password);
			if (!doc->isOk())
			{
				delete doc;
				spwd = query_password();
				password = new GooString(spwd);
				filename = new GooString(FileName);
				doc = new PDFDoc(filename, NULL, password);
				if (!doc->isOk())
				{
					Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
					return 0;
				}
			}
		}
		else
		{
			Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
			return 0;
		}
	}

	npages = doc->getNumPages();
	paperColor[0] = 255;
	paperColor[1] = 255;
	paperColor[2] = 255;
	splashOut = new MySplashOutputDev(USE4 ? splashModeMono4 : splashModeMono8, 4, gFalse, paperColor);
	splashOut->startDoc(doc->getXRef());

	Outline* outline = doc->getOutline();
	if (outline && outline->getItems())
	{

		GooList* items = outline->getItems();
		if (items->getLength() == 1)
		{
			OutlineItem* first = (OutlineItem*)items->get(0);
			first->open();
			items = first->getKids();
			update_toc(items, 0);
			first->close();
		}
		else if (items->getLength() > 1)
		{
			update_toc(items, 0);
		}

	}

	DataFile = GetAssociatedFile(FileName, 0);
	f = fopen(DataFile, "rb");
	if (f == NULL || fread(&docstate, 1, sizeof(tdocstate), f) != sizeof(tdocstate) || docstate.magic != 0x9751)
	{
		docstate.magic = 0x9751;
		docstate.page = 1;
		docstate.offx = 0;
		docstate.offy = 0;
		docstate.scale = 100;
		docstate.rscale = 150;
		docstate.orient = 0;
		docstate.nbmk = 0;
	}
	if (f != NULL) fclose(f);

	cpage = docstate.page;
	subpage = docstate.subpage;
	offx = docstate.offx;
	offy = docstate.offy;
	if (docstate.scale == 0)
	{
		scale = get_fit_scale();
		ScaleZoomType = ZoomTypeFitWidth;
	}
	else
	{
		scale = docstate.scale;
	}
	rscale = docstate.rscale;
	reflow_mode = (docstate.orient & 0x80) ? 1 : 0;

	gcfg = GetGlobalConfig();
//	ko = ReadInt(gcfg, "keeporient", 0);
	ko = -1;
	if (GetGlobalOrientation() == -1 || ko == 0)
	{
		orient = GetOrientation();
	}
	else
	{
		orient = docstate.orient & 0x7f;
		SetOrientation(orient);
	}

	if (argc >= 3)
	{
		if (argv[2][0] == '=')
		{
#ifdef USESYNOPSIS
			long long position;
			TSynopsisItem::PositionToLong(argv[2] + 1, &position);
			cpage = position_to_page(position >> 40);
#else
//			cpage = atoi(position_to_page(argv[2] + 1));
			cpage = atoi(argv[2] + 1);
#endif
		}
		else
		{
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId;
    int wmEvent;
    
    switch (message) 
    {
        case WM_COMMAND:
            wmId    = LOWORD(wParam); 
            wmEvent = HIWORD(wParam); 
            // Parse the menu selections:
            switch (wmId)
            {
                case IDM_ABOUT:
                    DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
                    break;
                case IDM_EXIT:
                    DestroyWindow(hWnd);
                    break;
                default:
                    return DefWindowProc(hWnd, message, wParam, lParam);
            }
            break;

        case WM_ERASEBKGND:
            return 1;

        case WM_PAINT:
            // Let's open some theme data, and using BufferedPainting draw different fonts on glass background
            {
                RECT rcClient;
                GetClientRect(hWnd, &rcClient);

                MARGINS marGlassInset = {-1, -1, -1, -1}; // -1 means the whole window
                DwmExtendFrameIntoClientArea(hWnd, &marGlassInset);

                PAINTSTRUCT ps;
                HDC    hdc    = BeginPaint(hWnd, &ps);
                // ControlPanelStyle is declared in AeroStyle.xml
                HTHEME hTheme = OpenThemeData(NULL, L"ControlPanelStyle"); 

                if (hTheme)
                {
                    HDC hdcPaint = NULL;

                    BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS) };
                    params.dwFlags        = BPPF_ERASE;

                    HPAINTBUFFER hBufferedPaint = BeginBufferedPaint(hdc, &rcClient, BPBF_TOPDOWNDIB, &params, &hdcPaint);
                    if (hdcPaint)
                    {
                        // Let's start with the simplest GDI default font
                        DTTOPTS DttOpts = {sizeof(DTTOPTS)};
                        DttOpts.dwFlags = DTT_COMPOSITED;
                        DrawText(hdcPaint, L"This is some GDI text in the default font", -1, &rcClient, 0);

                        // Let's look at the same text in the default theme
                        rcClient.top += RECT_INCREMENT;
                        DrawThemeTextEx(hTheme, hdcPaint, 0, 0, L"This is some text in the default font", -1, 0, &rcClient, &DttOpts);

                        // Let's add some text color to add to theming attributes and draw again
                        rcClient.top    += RECT_INCREMENT;
                        DttOpts.dwFlags |= DTT_TEXTCOLOR;
                        DttOpts.crText   = RGB(255, 255, 255);
                        // CPANEL_TASKLINK is declared in VSStyle.h
                        DrawThemeTextEx(hTheme, hdcPaint, CPANEL_TASKLINK, 0, L"This is some text in a themed font", -1, 0, &rcClient, &DttOpts);

                        // Draw text on glass in a selected font
                        DttOpts.dwFlags &= ~DTT_TEXTCOLOR;
                        LOGFONT lgFont;
                        HFONT hFontOld = NULL;
                        if (SUCCEEDED(GetThemeSysFont(hTheme, TMT_CAPTIONFONT, &lgFont)))
                        {
                            HFONT hFont = CreateFontIndirect(&lgFont);
                            hFontOld    = (HFONT) SelectObject(hdcPaint, hFont);
                        }

                        rcClient.top += RECT_INCREMENT;
                        DrawText(hdcPaint, L"This is some GDI text in the selected font", -1, &rcClient, 0);

                        // The same selected font in themed text
                        rcClient.top += RECT_INCREMENT;
                        DrawThemeTextEx(hTheme, hdcPaint, 0, 0, L"This is some text in the selected font", -1, 0, &rcClient, &DttOpts);

                        SelectObject(hdcPaint, hFontOld);
                        rcClient.top += RECT_INCREMENT;
                        DrawText(hdcPaint, L"This is some GDI text in the default font", -1, &rcClient, 0);

                        // Let's add glow to our text attributes
                        DttOpts.dwFlags |= DTT_GLOWSIZE;
                        DttOpts.iGlowSize = 12; // Default value
                        // CompositedWindow::Window is declared in AeroStyle.xml
                        HTHEME hThemeWindow = OpenThemeData(NULL, L"CompositedWindow::Window");
                        if (hThemeWindow != NULL)
                        {
                            GetThemeInt(hThemeWindow, 0, 0, TMT_TEXTGLOWSIZE, &DttOpts.iGlowSize);
                            CloseThemeData(hThemeWindow);
                        }

                        rcClient.top += RECT_INCREMENT;
                        DrawThemeTextEx(hTheme, hdcPaint, 0, 0, L"This is some text with glow in the default font", -1, 0, &rcClient, &DttOpts);

                        // Now some color(theme) and glow
                        DttOpts.dwFlags |= DTT_TEXTCOLOR;
                        DttOpts.crText   = RGB(255, 255, 255);

                        rcClient.top += RECT_INCREMENT;
                        // CPANEL_TASKLINK is declared in VSStyle.h
                        DrawThemeTextEx(hTheme, hdcPaint, CPANEL_TASKLINK, 0, L"This is some text with glow in a themed font", -1, 0, &rcClient, &DttOpts);

                        DttOpts.dwFlags &= ~DTT_TEXTCOLOR;

                        // Find a particular font and draw using this
                        if (SUCCEEDED(GetThemeSysFont(hTheme, TMT_CAPTIONFONT, &lgFont)))
                        {
                            HFONT hFont = CreateFontIndirect(&lgFont);
                            hFontOld    = (HFONT) SelectObject(hdcPaint, hFont);
                        }
                        
                        rcClient.top += RECT_INCREMENT;
                        DrawText(hdcPaint, L"This is some GDI text in the selected font", -1, &rcClient, 0);
                        
                        rcClient.top += RECT_INCREMENT;
                        DrawThemeTextEx(hTheme, hdcPaint, 0, 0, L"This is some text with glow in the selected font", -1, 0, &rcClient, &DttOpts);
                        
                        if (hFontOld)
                        {                        
                            SelectObject(hdcPaint, hFontOld);
                        }
                        EndBufferedPaint(hBufferedPaint, TRUE);
                    }
                    CloseThemeData(hTheme);
                }
                EndPaint(hWnd, &ps);
            }
            break;
        
        case WM_DESTROY:
            PostQuitMessage(0);
            BufferedPaintUnInit();
            break;
        
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
BOOL CXTPSkinManagerClass::GetThemePartSize(int iPartId, int iStateId, RECT *pRect, int eSize, SIZE* pSize)
{
    if (GetThemeEnumValue(iPartId, iStateId, TMT_BGTYPE) != BT_IMAGEFILE)
        return FALSE;

    int nImageFile = (GetThemeEnumValue(iPartId, iStateId, TMT_IMAGESELECTTYPE) != IST_NONE) &&
                     (GetThemeEnumValue(iPartId, iStateId, TMT_GLYPHTYPE, GT_NONE) == GT_NONE) ?
                     TMT_IMAGEFILE1: TMT_IMAGEFILE;

    CString strImageFile = GetThemeString(iPartId, iStateId, nImageFile);
    if (strImageFile.IsEmpty())
    {
        if (nImageFile != TMT_IMAGEFILE1)
            return FALSE;

        strImageFile = GetThemeString(iPartId, iStateId, TMT_IMAGEFILE);
        if (strImageFile.IsEmpty())
            return FALSE;

    }


    CXTPSkinImage* pImage = GetImages()->LoadFile(m_pSchema->GetResourceFile(), strImageFile);
    if (!pImage)
    {
        return FALSE;
    }

    int nImageCount = GetThemeInt(iPartId, iStateId, TMT_IMAGECOUNT, 1);
    if (nImageCount < 1)
        nImageCount = 1;

    BOOL bHorizontalImageLayout = GetThemeEnumValue(iPartId, iStateId, TMT_IMAGELAYOUT, IL_HORIZONTAL) == IL_HORIZONTAL;

    CSize sz(pImage->GetWidth(), pImage->GetHeight());
    if (bHorizontalImageLayout) sz.cx /= nImageCount;
    else sz.cy /= nImageCount;

    if (eSize == TS_TRUE)
    {
        *pSize = sz;
    }
    if (eSize == TS_DRAW)
    {
        if (GetThemeEnumValue(iPartId, iStateId, TMT_SIZINGTYPE, ST_STRETCH) == ST_TRUESIZE)
        {
            *pSize = sz;
            return TRUE;
        }

        if (!pRect)
        {
            pSize->cy = 0;
            pSize->cx = 0;
        }
        else
        {
            pSize->cy = pRect->bottom - pRect->top;
            pSize->cx = pRect->right - pRect->left;
        }

        if (GetThemeBool(iPartId, iStateId, TMT_UNIFORMSIZING, FALSE))
        {
            pSize->cx = MulDiv(pSize->cy, sz.cx, sz.cy);
        }
    }

    return TRUE;
}
예제 #9
0
파일: XpTheme.cpp 프로젝트: aminsyed/rulib
int CXpTheme::GetThemeInt(int iPartId, int iStateId, int iPropId, int iDefault)
{_STT();
	int i = iDefault;
	if ( GetThemeInt( iPartId, iStateId, iPropId, &i ) ) return i;
	return iDefault;
}