예제 #1
0
파일: gdd_region.c 프로젝트: Mars-Wu/djyos
void    SetRect(RECT *prc,int x,int y,int w,int h)
{
    if(prc!=NULL)
    {
        _SetRect(prc,x,y,w,h);
    }
}
예제 #2
0
void
PreviewView::Update(const BRect* rect, BBitmap* bitmap)
{
	if (rect != NULL)
		_SetRect(*rect);

	if (bitmap == NULL && Window() != NULL) {
		BScreen screen(Window());
		screen.GetBitmap(&bitmap, false, &fCoordRect);
	}
	if (bitmap != NULL) {
		fBitmapView->SetViewBitmap(bitmap,
			bitmap->Bounds().OffsetToCopy(B_ORIGIN),
			fBitmapView->Bounds(),
			B_FOLLOW_TOP|B_FOLLOW_LEFT, 0);
		if (Window() != NULL)
			Invalidate();
	}
}
예제 #3
0
void
PreviewView::Update(const BRect* rect, BBitmap* bitmap)
{
	if (Window() == NULL || Window()->IsHidden())
		return;

	if (rect != NULL)
		_SetRect(*rect);

	bigtime_t now = system_time();
	if (bitmap == NULL) {
		// Avoid updating preview too often
		if (fTimeStamp + 50000 >= now)
			return;
		BScreen screen(Window());
		screen.GetBitmap(&bitmap, false, &fCoordRect);
	}
	if (bitmap != NULL) {
		BRect destRect;
		BRect bitmapBounds = bitmap->Bounds();
		BRect viewBounds = fBitmapView->Bounds();
		if (BRectRatio(viewBounds) >= BRectRatio(bitmapBounds)) {
			float overlap = BRectHorizontalOverlap(viewBounds, bitmapBounds);
			destRect.Set(-overlap, 0, viewBounds.Width() + overlap,
						viewBounds.Height());
		} else {
			float overlap = BRectVerticalOverlap(viewBounds, bitmapBounds);
			destRect.Set(0, -overlap, viewBounds.Width(), viewBounds.Height() + overlap);
		}
		fTimeStamp = now;
		fBitmapView->SetViewBitmap(bitmap,
			bitmap->Bounds().OffsetToCopy(B_ORIGIN),
			destRect,
			B_FOLLOW_TOP|B_FOLLOW_LEFT, B_FILTER_BITMAP_BILINEAR);
		Invalidate();
	}
}
예제 #4
0
파일: Toolbar.cpp 프로젝트: fin-alice/bb4nt
//===========================================================================
void PaintToolbar(HDC hdc, RECT *rcPaint)
{
	RECT r; int i; const TCHAR *label = Toolbar_CurrentWindow; StyleItem *pSI;

#ifdef BBOPT_MEMCHECK
	// Display some statistics.
#pragma message("\n"__FILE__ "(397) : warning 0: MEMCHECK enabled.\n")
	/*
    if (NULL==Toolbar_hFont)
    {
        LOGFONT logFont;
        SystemParametersInfo(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
        Toolbar_hFont = CreateFontIndirect(&logFont);
    }
	 */
	extern int g_menu_count;
	extern int g_menu_item_count;
	TCHAR temp[256];
	if (alloc_size && false == Toolbar_ShowingExternalLabel)
	{
		_stprintf(temp,_T("Menus %d  MenuItems %d  Memory %d"), g_menu_count, g_menu_item_count, alloc_size);
		label = temp;

	}
#endif

	int tbW = TBInfo.width;
	int tbH = TBInfo.height;
	HDC buf = CreateCompatibleDC(NULL);
	HGDIOBJ bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH));

	if (NULL==Toolbar_hFont) Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar);
	HGDIOBJ other_font = SelectObject(buf, Toolbar_hFont);

	// Get width of clock...
	SIZE size;

	GetTextExtentPoint32(buf, Toolbar_CurrentTime, (int)_tcsnlen(Toolbar_CurrentTime,0x7FFFFFFFUL), &size);
	size.cx += 6;
	if (tbClockW < size.cx) tbClockW = size.cx + 6;

	GetTextExtentPoint32(buf, Toolbar_WorkspaceName, (int)_tcsnlen(Toolbar_WorkspaceName,0x7FFFFFFFUL), &size);
	int tbLabelW = size.cx + 6;

	// The widest sets the width!
	tbLabelW = tbClockW = (int)imax(tbH * 2, imax(tbLabelW, tbClockW));

	int margin = tbMargin;
	int border = mStyle.Toolbar.borderWidth;
	int border_margin = margin + border;
	int button_padding = (tbH - tbButtonWH) / 2 - border;

	int tbLabelX = border_margin;
	int tbClockX = tbW - tbClockW - border_margin;
	int two_buttons = 2*tbButtonWH + 3*button_padding;
	int tbWinLabelX = tbLabelX + tbLabelW + two_buttons;
	int tbWinLabelW = tbClockX - tbWinLabelX - two_buttons;
	if (tbWinLabelW < 0) tbWinLabelW = 0;

	Toolbar_Button[0].r.left = tbLabelX + tbLabelW + button_padding;
	Toolbar_Button[1].r.left = Toolbar_Button[0].r.left + tbButtonWH + button_padding;
	Toolbar_Button[2].r.left = tbClockX - 2*tbButtonWH - 2*button_padding;
	Toolbar_Button[3].r.left = Toolbar_Button[2].r.left + tbButtonWH + button_padding;

	Toolbar_Button[4].r.left = tbClockX;
	for (i = 0; i<5; i++)
	{
		Toolbar_Button[i].r.top    = (tbH - tbButtonWH) / 2;
		Toolbar_Button[i].r.bottom = Toolbar_Button[i].r.top + tbButtonWH;
		Toolbar_Button[i].r.right  = Toolbar_Button[i].r.left + tbButtonWH;
	}
	Toolbar_Button[4].r.right = tbClockX + tbClockW;

	//====================

	// Paint toolbar Style
	_SetRect(&r, 0, 0, tbW, tbH); pSI = &mStyle.Toolbar;
	MakeStyleGradient(buf, &r, pSI, true);

	//====================
	// Paint unpressed workspace/task buttons...

	r.left = r.top = 0; r.right = r.bottom = tbButtonWH;
	{
		HPEN activePen   = CreatePen(PS_SOLID, 1, mStyle.ToolbarButtonPressed.picColor);
		HPEN inactivePen = CreatePen(PS_SOLID, 1, mStyle.ToolbarButton.picColor);
		HDC src = CreateCompatibleDC(NULL);
		HGDIOBJ srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH));
		int yOffset = tbH / 2; int xOffset; int f1 = -1;
		for (i=0; i<4; i++)
		{
			int f2 = Toolbar_Button[i].pressed || (Toolbar_force_button_pressed && i&1);
			pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton;

			if (pSI->parentRelative)
			{
				CreateBorder(buf, &r, pSI->borderColor, pSI->borderWidth);
			}
			else
			{
				if (f1 != f2)
					MakeStyleGradient(src, &r, pSI, pSI->bordered), f1 = f2;

				BitBlt(buf,
					   Toolbar_Button[i].r.left,
					   Toolbar_Button[i].r.top,
					   tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY
					   );
			}

			xOffset = Toolbar_Button[i].r.left + (tbButtonWH / 2);
			HGDIOBJ penother = SelectObject(buf, f2 ? activePen : inactivePen);
			arrow_bullet(buf, xOffset, yOffset, (i&1)*2-1);
			SelectObject(buf, penother);
		}

		DeleteObject(SelectObject(src, srcother));
		DeleteDC(src);
		DeleteObject(inactivePen);
		DeleteObject(activePen);
	}

	//====================

	r.top = (tbH - tbLabelH)/2;
	r.bottom = r.top + tbLabelH;
	SetBkMode(buf, TRANSPARENT);
	int justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX);

	// Paint workspaces background...
	r.right = (r.left = tbLabelX) + tbLabelW; pSI = &mStyle.ToolbarLabel;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, Toolbar_WorkspaceName, -1, &r, justify, pSI);

	// Paint window label background...
	r.right = (r.left = tbWinLabelX) + tbWinLabelW; pSI = &mStyle.ToolbarWindowLabel;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, label, -1, &r, justify, pSI);

	// Paint clock background...
	r.right = (r.left = tbClockX) + tbClockW; pSI = &mStyle.ToolbarClock;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, Toolbar_CurrentTime, -1, &r, justify, pSI);

	//====================

	BitBltRect(hdc, buf, rcPaint);

	SelectObject(buf, other_font);
	DeleteObject(SelectObject(buf, bufother));
	DeleteDC(buf);
}
예제 #5
0
파일: gdd_window.c 프로젝트: Mars-Wu/djyos
//----初始化窗口数据结构---------------------------------------------------------
//描述: 该函数为内部调用.
//参数:pwin:窗口数据结构指针.
//      proc:窗口过程回调函数指针.
//      Text:窗口文字内容指针.
//      Style:窗口风格.
//      x,y,w,h:窗口位置和大小.
//      hParent:父窗口句柄.
//      WinId: 窗口Id.
//返回:无.
//------------------------------------------------------------------------------
static  void    _InitWindow(WINDOW *pwin,WNDPROC *proc,const char *Text,u32 Style,
                            int x,int y,int w,int h,HWND hParent,u32 WinId)
{
    RECT rc;

    _SetRect(&rc,x,y,w,h);
    pwin->Parent =hParent;
    pwin->Child  =NULL;
    pwin->Prev  =NULL;
    pwin->Next  =NULL;
    pwin->PrivateData =NULL;
    pwin->UserData    =NULL;
    pwin->WndProc   =proc;

    //pwin->Text        =Text;
    strncpy(pwin->Text,Text,250);
    itoa((u32)pwin,pwin->Name,16);

    pwin->Style     =Style;
    pwin->WinId     =WinId&0x0000FFFF;
    list_init(&pwin->list_timer);
    list_init(&pwin->node_msg_close);
    list_init(&pwin->node_msg_ncpaint);
    list_init(&pwin->node_msg_paint);

    if(hParent != NULL)
    {
        _ClientToScreen(hParent,(POINT*)&rc,2);
    }

    _CopyRect(&pwin->WinRect,&rc);

    if(Style&WS_BORDER)
    {
        pwin->BorderSize =DEF_BORDER_SIZE;
        _InflateRectEx(&rc, -DEF_BORDER_SIZE,
                            -DEF_BORDER_SIZE,
                            -DEF_BORDER_SIZE,
                            -DEF_BORDER_SIZE);

    }
    else
    {
        pwin->BorderSize =0;
    }

    if(Style&WS_DLGFRAME)
    {
        pwin->DlgFrameSize =DEF_DLGFRAME_SIZE;
        _InflateRectEx(&rc, -DEF_DLGFRAME_SIZE,
                            -DEF_DLGFRAME_SIZE,
                            -DEF_DLGFRAME_SIZE,
                            -DEF_DLGFRAME_SIZE);
    }
    else
    {
        pwin->DlgFrameSize =0;
    }

    if(Style&WS_CAPTION)
    {
        pwin->CaptionSize =DEF_CAPTION_SIZE;
        _InflateRectEx(&rc,0,-DEF_CAPTION_SIZE,0,0);
    }
    else
    {
        pwin->CaptionSize =0;
    }
    _CopyRect(&pwin->CliRect,&rc);

}