static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
{
    static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL };

    RECT bgRect, textRect, contentRect;
    int state = states[ drawState ];
    WCHAR *text = get_button_text(hwnd);
    LOGFONTW lf;
    HFONT font, hPrevFont = NULL;
    BOOL created_font = FALSE;

    HRESULT hr = GetThemeFont(theme, hDC, BP_GROUPBOX, state, TMT_FONT, &lf);
    if (SUCCEEDED(hr)) {
        font = CreateFontIndirectW(&lf);
        if (!font)
            TRACE("Failed to create font\n");
        else {
            hPrevFont = SelectObject(hDC, font);
            created_font = TRUE;
        }
    } else {
        font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0);
        hPrevFont = SelectObject(hDC, font);
    }

    GetClientRect(hwnd, &bgRect);
    textRect = bgRect;

    if (text)
    {
        SIZE textExtent;
        GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent);
        bgRect.top += (textExtent.cy / 2);
        textRect.left += 10;
        textRect.bottom = textRect.top + textExtent.cy;
        textRect.right = textRect.left + textExtent.cx + 4;

        ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom);
    }

    GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
    ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);

    if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
        DrawThemeParentBackground(hwnd, hDC, NULL);
    DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);

    SelectClipRgn(hDC, NULL);

    if (text)
    {
        InflateRect(&textRect, -2, 0);
        DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect);
        HeapFree(GetProcessHeap(), 0, text);
    }

    if (created_font) DeleteObject(font);
    if (hPrevFont) SelectObject(hDC, hPrevFont);
}
Ejemplo n.º 2
0
//
//    Clip a card SHAPE - basically any rectangle
//  with rounded corners
//
int ClipCard(HDC hdc, int x, int y, int width, int height)
{
    ExcludeClipRect(hdc, x+2,        y,     x+2+width-4, y+  height);
    ExcludeClipRect(hdc, x,            y+2, x+1,          y+2+height-4);
    ExcludeClipRect(hdc, x+1,        y+1, x+2,          y+1+height-2);
    ExcludeClipRect(hdc, x+width-2, y+1, x+width-2+1, y+1+height-2);
    ExcludeClipRect(hdc, x+width-1, y+2, x+width-1+1, y+2+height-4);
    return 0;
}
Ejemplo n.º 3
0
//
//	Draw a rectangle in a single colour. Depending on the run-direction (left/right),
//	the rectangle's position may need to be mirrored within the run before output
//
static 
void PaintRectBG(USPDATA *uspData, ITEM_RUN *itemRun, HDC hdc, int xpos, RECT *rect, ATTR *attr)
{
	RECT rc = *rect;
	
	// rectangle must be mirrored within the run for RTL scripts
	if(itemRun->analysis.fRTL)
	{
		int rtlOffset = xpos*2 + itemRun->width - rc.right - rc.left;
		OffsetRect(&rc, rtlOffset, 0);
	}
	
	// draw selection highlight + add to clipping region
	if(attr->sel)
	{
		SetBkColor(hdc, uspData->selBG);
		ExtTextOut(hdc, 0, 0, ETO_OPAQUE|ETO_CLIPPED, &rc, 0, 0, 0);
		ExcludeClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
	}
	// draw normal background 
	else
	{
		SetBkColor(hdc, attr->bg);
		ExtTextOut(hdc, 0, 0, ETO_OPAQUE|ETO_CLIPPED, &rc, 0, 0, 0);
	}
}
Ejemplo n.º 4
0
BOOL CSaverWnd::OnPaint()
{
    PAINTSTRUCT ps ;
    BeginPaint(m_hWnd, &ps) ;
    
    RECT rc ;
    ::GetClientRect(m_hWnd, &rc) ;
    FillRect(ps.hdc, &rc, (HBRUSH)(COLOR_WINDOW+1)) ;
    FrameRect(ps.hdc, &rc, (HBRUSH)GetStockObject(GRAY_BRUSH)) ;
    RECT rc2 ;
    int height ;
    rc2 = rc ;
    height = DrawText(ps.hdc, "Kaspersky", -1, &rc, DT_WORDBREAK | DT_CENTER | DT_CALCRECT) ;
    rc = rc2 ;

    rc2.top = (rc.bottom + rc.top - height) / 2 ;

    DrawText(ps.hdc, "Kaspersky", -1, &rc2, DT_WORDBREAK | DT_CENTER ) ;

    ExcludeClipRect(ps.hdc, rc.left, rc.top, rc.right, rc.bottom) ;
    ScreenToClient(m_hWnd, (POINT*)&rc.left) ;
    ScreenToClient(m_hWnd, (POINT*)&rc.right) ;
    FillRect(ps.hdc, &rc, (HBRUSH)GetStockObject(GRAY_BRUSH)) ;
    
    EndPaint(m_hWnd, &ps) ;

    return TRUE ;
}
Ejemplo n.º 5
0
void hm_wmp_drawtrigger_nca::_doTrigger( hm_keel_obj* pKeelObj, HDC hDC, HWND hWnd ) {
	RECT rcWnd;
	RECT rcClient;
	RECT rcC2W;
	SIZE sizeWnd;

	if ( !::GetWindowRect( hWnd, &rcWnd ) )
		return;
	sizeWnd.cx = rcWnd.right - rcWnd.left;
	sizeWnd.cy = rcWnd.bottom - rcWnd.top;

	//
	pKeelObj->doDrawAll( m_hmCanvas.GetMemDC(), hWnd );

	//
	::GetClientRect( hWnd, &rcClient );
	rcC2W = rcClient;
	::ClientToScreen( hWnd, (LPPOINT)(&rcC2W) );
	::ClientToScreen( hWnd, ((LPPOINT)(&rcC2W)) + 1 );
	rcC2W.left -= rcWnd.left;
	rcC2W.top -= rcWnd.top;
	rcC2W.right -= rcWnd.left;
	rcC2W.bottom -= rcWnd.top;
	ExcludeClipRect( hDC, rcC2W.left, rcC2W.top, rcC2W.right, rcC2W.bottom );
	::BitBlt( hDC, 0, 0, sizeWnd.cx, sizeWnd.cy, m_hmCanvas.GetMemDC(), 0, 0, SRCCOPY );


}
Ejemplo n.º 6
0
LRESULT CWENavigatorDlg::OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	HDC hDC = (HDC)wParam;

	CRect client;
	GetClientRect(&client);

	int state = SaveDC(hDC);

	if (m_layoutView)
	{
		CRect rect;
		rect.left = 3 + (client.Width()-6-m_size.cx)/2;
		rect.top = 3 + (client.Height()-6-16-m_size.cy)/2;
		rect.right = rect.left + m_size.cx;
		rect.bottom = rect.top + m_size.cy;

		rect.InflateRect(2, 2);

		ExcludeClipRect(hDC, rect.left, rect.top, rect.right, rect.bottom);
	}

	FillSolidRect(hDC, &client, GetSysColor(COLOR_BTNFACE));

	RestoreDC(hDC, state);

	return TRUE;
}
Ejemplo n.º 7
0
	void TitleBar::excludeFromClipRegion() const
	{
		if (m_hasTitleBar)
		{
			const RECT& r = m_tbi.rcTitleBar;
			ExcludeClipRect(m_compatDc, r.left, r.top, r.right, r.bottom);
		}
	}
Ejemplo n.º 8
0
static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags)
{
    static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL };

    RECT bgRect, textRect, contentRect;
    HFONT font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0);
    HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL;
    int state = states[ drawState ];
    WCHAR *text = get_button_text(hwnd);

    GetClientRect(hwnd, &bgRect);
    textRect = bgRect;

    if (text)
    {
        SIZE textExtent;
        GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent);
        bgRect.top += (textExtent.cy / 2);
        textRect.left += 10;
        textRect.bottom = textRect.top + textExtent.cy;
        textRect.right = textRect.left + textExtent.cx + 4;

        ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom);
    }

    GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
    ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);

    if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
        DrawThemeParentBackground(hwnd, hDC, NULL);
    DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);

    SelectClipRgn(hDC, NULL);

    if (text)
    {
        textRect.left += 2;
        textRect.right -= 2;
        DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect);
        HeapFree(GetProcessHeap(), 0, text);
    }

    if (hPrevFont) SelectObject(hDC, hPrevFont);
}
Ejemplo n.º 9
0
BOOL CFlexWnd::RenderIntoClipChild(HWND hChild)
{
	if (m_hRenderInto != NULL && HasWnd() && hChild && IsWindowVisible(hChild))
	{
		RECT rect;
		GetWindowRect(hChild, &rect);
		POINT ul = {rect.left, rect.top}, lr = {rect.right, rect.bottom};
		ScreenToClient(m_hWnd, &ul);
		ScreenToClient(m_hWnd, &lr);
		ExcludeClipRect(m_hRenderInto, ul.x, ul.y, lr.x, lr.y);
	}
	return TRUE;
}
Ejemplo n.º 10
0
CBufferDC::CBufferDC (HDC hDestDC, const CRect& rcPaint) : m_hDestDC (hDestDC)
{
    if ( rcPaint.IsRectEmpty() )
    {
        ::GetClipBox (m_hDestDC, m_rect);
    }
    else
    {
        m_rect = rcPaint;
    }
    Attach (::CreateCompatibleDC (m_hDestDC));
    m_bitmap.Attach (::CreateCompatibleBitmap (m_hDestDC, m_rect.right, m_rect.bottom));
    m_hOldBitmap = ::SelectObject (m_hDC, m_bitmap);

    if ( m_rect.top > 0 )
    {
        ExcludeClipRect (0, 0, m_rect.right, m_rect.top);
    }
    if ( m_rect.left > 0 )
    {
        ExcludeClipRect (0, m_rect.top, m_rect.left, m_rect.bottom);
    }
}
Ejemplo n.º 11
0
/////////////////////////////////////////////////////////////////////
// TMapDC
// -------------
// Exclude a window from the DC clipping region
//
void
TMapDC::ExcludeClipWindow (TWindow *pWnd)
{
	TRect wRect;
	pWnd->GetWindowRect (wRect);

	TPoint TopLeft (wRect.left, wRect.top);
	TPoint BotRight (wRect.right, wRect.bottom);

	pEditor->ScreenToClient (TopLeft);
	pEditor->ScreenToClient (BotRight);

	ExcludeClipRect (TRect (TopLeft, BotRight));
}
Ejemplo n.º 12
0
bool SystemDraw::ExcludeClipOp(const Rect& r)
{
    GuiLock __;
#ifdef PLATFORM_WINCE
    int q = ExcludeClipRect(handle, r.left, r.top, r.right, r.bottom);
#else
    LTIMING("ExcludeClip");
    if(r.Contains(drawingclip))
        drawingclip = Rect(0, 0, 0, 0);
    Rect rr = LPtoDP(r);
    HRGN hrgn = ::CreateRectRgnIndirect(rr);
    int q = ::ExtSelectClipRgn(handle, hrgn, RGN_DIFF);
    ASSERT(q != ERROR);
    ::DeleteObject(hrgn);
#endif
    return q == SIMPLEREGION || q == COMPLEXREGION;
}
Ejemplo n.º 13
0
static void	__fastcall Repaint(HWND	hWnd,RECT & updata,RECT& upbmp,HDC hdc)
{
	PAINTSTRUCT ps={0};
	HDRAWDIB	hdd;
	HBITMAP		hbmp;
	BITMAPINFOHEADER	bi={sizeof(bi)};
	void*		bits=LocalAlloc(LPTR,4096*4096*5);
	
	POINTS	bmprc;
	*((DWORD*)(&bmprc))= GetWindowLong(hWnd,FIELD_OFFSET(ShowPicClass,bmRC));

	hdd=DrawDibOpen();

	if(!hdc)
		hdc =BeginPaint(hWnd,&ps);

	hbmp=(HBITMAP)GetWindowLong(hWnd,FIELD_OFFSET(ShowPicClass,hbmp));
	
	BITMAP	bm;

	GetObject(hbmp,sizeof(bm),&bm);
	bi.biBitCount=32;
	bi.biWidth = bm.bmWidth;
	bi.biPlanes = 1;
	bi.biHeight = bm.bmHeight ;
	
	ExcludeClipRect(hdc,updata.left,updata.top,updata.right,updata.bottom);

	FillRect(hdc,&ps.rcPaint,(HBRUSH)1);
	
	SelectClipRgn(hdc,NULL);

	GetDIBits(hdc,hbmp,0,bi.biHeight,bits,(LPBITMAPINFO)&bi,DIB_RGB_COLORS);

	DrawDibDraw(hdd,hdc,updata.left,updata.top,updata.right-updata.left,updata.bottom-updata.top,
		&bi,bits,upbmp.left,upbmp.top,upbmp.right-upbmp.left,upbmp.bottom-upbmp.top,0);
	
	LocalFree(bits);

	DrawDibClose(hdd);
	
	if(ps.hdc)
		EndPaint(hWnd,&ps);
	
}
Ejemplo n.º 14
0
void COFSNcDlg2::DrawBackground(CDC *pDC)
{
	HDC hDC = pDC->GetSafeHdc();

	RECT r;
	CPictureObj *pic = NULL;
	int n = m_aPictures.GetSize();
	while(n > 0)
	{
		n--;
		pic = m_aPictures.GetAt(n);
		if(pic)
		{
			pic->Render(hDC);
			pic->GetRect(&r);
			ExcludeClipRect(hDC, r.left, r.top, r.right, r.bottom);
		}
	}
}
Ejemplo n.º 15
0
void IF_PaintWindow(CPs_InterfaceWindowState* pState, CPs_DrawContext* pContext)
{
	// Walk through list drawing and adding to the valid rects list
	CPs_InterfacePart* pSubPart_Cursor;
	
	for (pSubPart_Cursor = pState->m_pFirstSubPart; pSubPart_Cursor; pSubPart_Cursor = (CPs_InterfacePart*)pSubPart_Cursor->m_hNext)
	{
		if (pSubPart_Cursor->Draw)
		{
			pSubPart_Cursor->Draw(pSubPart_Cursor, pContext);
			ExcludeClipRect(pContext->m_dcDraw,
							pSubPart_Cursor->m_rLocation.left, pSubPart_Cursor->m_rLocation.top,
							pSubPart_Cursor->m_rLocation.right, pSubPart_Cursor->m_rLocation.bottom);
		}
	}
	
	// Perform callback
	
	if (pState->m_hndlr_onDraw)
		pState->m_hndlr_onDraw(pState, pContext);
}
Ejemplo n.º 16
0
static void winFrameDrawItem(Ihandle* ih, DRAWITEMSTRUCT *drawitem)
{ 
  iupwinBitmapDC bmpDC;
  HDC hDC = iupwinDrawCreateBitmapDC(&bmpDC, drawitem->hDC, drawitem->rcItem.right-drawitem->rcItem.left, 
                                                            drawitem->rcItem.bottom-drawitem->rcItem.top);

  iupwinDrawParentBackground(ih, hDC, &drawitem->rcItem);

  if (iupAttribGet(ih, "_IUPFRAME_HAS_TITLE"))
  {
    int x, y;
    HFONT hOldFont, hFont = (HFONT)iupwinGetHFontAttrib(ih);
    int txt_height = iupFrameGetTitleHeight(ih);
    COLORREF fgcolor;
    SIZE size;

    char* title = iupdrvBaseGetTitleAttrib(ih);
    if (!title) title = "";

    x = drawitem->rcItem.left+7;
    y = drawitem->rcItem.top;

    hOldFont = SelectObject(hDC, hFont);
    GetTextExtentPoint32(hDC, title, strlen(title), &size);
    ExcludeClipRect(hDC, x-2, y, x+size.cx+2, y+size.cy);

    drawitem->rcItem.top += txt_height/2;
    if (iupwin_comctl32ver6)
      iupwinDrawThemeFrameBorder(ih->handle, hDC, &drawitem->rcItem, drawitem->itemState);
    else
      DrawEdge(hDC, &drawitem->rcItem, EDGE_ETCHED, BF_RECT);

    SelectClipRgn(hDC, NULL);

    if (drawitem->itemState & ODS_DISABLED)
      fgcolor = GetSysColor(COLOR_GRAYTEXT);
    else
    {
      unsigned char r, g, b;
      char* color = iupAttribGetInherit(ih, "FGCOLOR");
      if (!color)
      {
        if (!iupwinDrawGetThemeFrameFgColor(ih->handle, &fgcolor))
          fgcolor = 0;  /* black */
      }
      else
      {
        if (iupStrToRGB(color, &r, &g, &b))
          fgcolor = RGB(r,g,b);
        else
          fgcolor = 0;  /* black */
      }
    }

    winFrameDrawText(hDC, title, x, y, fgcolor);

    SelectObject(hDC, hOldFont);
  }
  else
  {
    char* value = iupAttribGetStr(ih, "SUNKEN");
    if (iupStrBoolean(value))
      DrawEdge(hDC, &drawitem->rcItem, EDGE_SUNKEN, BF_RECT);
    else
      DrawEdge(hDC, &drawitem->rcItem, EDGE_ETCHED, BF_RECT);
  }

  iupwinDrawDestroyBitmapDC(&bmpDC);
}
Ejemplo n.º 17
0
// 
//******************************************************************
//  Function Name : OnNcPaint
//  Function      : QA: 32574
//  Param         : HRGN hrgnUpdate
//  Return        : LRESULT 
//  Create        : 
//  Update        : ±èÁ¤¹®, 2009/10/09 VS 2008 Upgrade¸¦ À§ÇÑ ÀÛ¾÷
//  Comment       : 
//******************************************************************
LRESULT SECTreeCtrl::OnNcPaint(HRGN hrgnUpdate)
{
	if(!m_hTreeTheme)
	{
#ifndef __RWUXTHEME_H
		m_hTreeTheme = RWOpenThemeData(m_hWnd, L"TREEVIEW");
#endif
	}

	if(m_hTreeTheme)
	{
		//---------------------//
		// Draw Themed Border  //
		//---------------------//

		HDC hdc = ::GetWindowDC(m_hWnd);
		RECT rc;
		RECT rcWindow;
		DWORD state = ETS_NORMAL;
		HRGN hrgnClip;

		// State
		if(!::IsWindowEnabled(this->GetSafeHwnd()))
		{
			state = ETS_DISABLED;
		}else if(GetFocus() == this->GetParent())
		{
			state = ETS_HOT;
		}else
		{
			state = ETS_NORMAL;
		}

		// Rect mapping
		::GetWindowRect(m_hWnd, &rcWindow);
		::GetClientRect(m_hWnd, &rc);
		::ClientToScreen(m_hWnd, (POINT *)&rc.left);
		::ClientToScreen(m_hWnd, (POINT *)&rc.right);

		rc.right = rcWindow.right - (rc.left - rcWindow.left);
		rc.bottom = rcWindow.bottom - (rc.top - rcWindow.top);

		// Region
		hrgnClip = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);

		if(hrgnUpdate != (HRGN)1)
		CombineRgn(hrgnClip, hrgnClip, hrgnUpdate, RGN_AND);

		OffsetRect(&rc, -rcWindow.left, -rcWindow.top);

		ExcludeClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
		OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top);

		//if (IsThemeBackgroundPartiallyTransparent (m_hTreeTheme, TVP_TREEITEM, state))
		//RWDrawThemeParentBackground(m_hWnd, hdc, &rcWindow);
#ifndef __RWUXTHEME_H
		RWDrawThemeBackground(m_hTreeTheme, hdc,
		TVP_TREEITEM, 
		state,
		&rcWindow, NULL);
#endif
		::ReleaseDC(m_hWnd, hdc);
	}

	return 0; 
}
Ejemplo n.º 18
0
static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
#endif
{
    static const int states[] = { GBS_NORMAL, GBS_NORMAL, GBS_NORMAL, GBS_DISABLED, GBS_NORMAL };

    RECT bgRect, textRect, contentRect;
    int state = states[ drawState ];
    WCHAR *text = get_button_text(hwnd);
    LOGFONTW lf;
    HFONT font, hPrevFont = NULL;
    BOOL created_font = FALSE;
#ifdef __REACTOS__ /* r74406 */
    HWND parent;
    HBRUSH hBrush;
    RECT clientRect;
#endif

    HRESULT hr = GetThemeFont(theme, hDC, BP_GROUPBOX, state, TMT_FONT, &lf);
    if (SUCCEEDED(hr)) {
        font = CreateFontIndirectW(&lf);
        if (!font)
            TRACE("Failed to create font\n");
        else {
            hPrevFont = SelectObject(hDC, font);
            created_font = TRUE;
        }
    } else {
#ifdef __REACTOS__ /* r73885 */
        font = get_button_font(hwnd);
#else
        font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0);
#endif
        hPrevFont = SelectObject(hDC, font);
    }

    GetClientRect(hwnd, &bgRect);
    textRect = bgRect;

    if (text)
    {
        SIZE textExtent;
        GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent);
        bgRect.top += (textExtent.cy / 2);
        textRect.left += 10;
        textRect.bottom = textRect.top + textExtent.cy;
        textRect.right = textRect.left + textExtent.cx + 4;

        ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom);
    }

    GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
    ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);

#ifdef __REACTOS__ /* r73885 & r74149 */
    if (prfFlag == 0)
    {
        if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
            DrawThemeParentBackground(hwnd, hDC, NULL);
    }
#else
    if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
        DrawThemeParentBackground(hwnd, hDC, NULL);
#endif

#ifdef __REACTOS__ /* r74406 */
    parent = GetParent(hwnd);
    if (!parent) parent = hwnd;
    hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
                                  (WPARAM)hDC, (LPARAM)hwnd);
    if (!hBrush) /* did the app forget to call defwindowproc ? */
        hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
                                       (WPARAM)hDC, (LPARAM)hwnd );
    GetClientRect(hwnd, &clientRect);
    FillRect( hDC, &clientRect, hBrush );
#endif

    DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);

    SelectClipRgn(hDC, NULL);

    if (text)
    {
        InflateRect(&textRect, -2, 0);
        DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect);
        HeapFree(GetProcessHeap(), 0, text);
    }

    if (created_font) DeleteObject(font);
    if (hPrevFont) SelectObject(hDC, hPrevFont);
}
Ejemplo n.º 19
0
void sClipExclude(const sRect &r)
{
  ExcludeClipRect(sGDIDC,r.x0,r.y0,r.x1,r.y1);
}
Ejemplo n.º 20
0
LRESULT CALLBACK Viewer::WndProcViewer(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    WORD id;
    POINTS pts;
    Viewer *v;

    if(!g_viewer) goto exit1;
    v=g_viewer;

    switch(msg) {
    case WM_ERASEBKGND:
        return 1;
    case WM_PAINT:
    {
        PAINTSTRUCT paintStruct;
        HDC hdc;
        HBRUSH hbr1;
        int rv;

        hdc = BeginPaint(hwnd, &paintStruct);

        if(v->m_dib) {

            v->GoodScrollPos();

            // paint the image
            SetStretchBltMode(hdc,COLORONCOLOR);
            rv=StretchDIBits(hdc,
                             v->m_imgpos_x,v->m_imgpos_y,v->m_stretchedwidth,v->m_stretchedheight,
                             0,0,v->m_dib->biWidth,v->m_dib->biHeight,
                             v->m_bits,(LPBITMAPINFO)v->m_dib,
                             DIB_RGB_COLORS,SRCCOPY);
            if(rv==GDI_ERROR || rv<1) {
                RECT r1;
                // Failure probably means we've exceeded the video system's
                // stretching limits. Draw a black rectangle instead.
                r1.left=v->m_imgpos_x;
                r1.top=v->m_imgpos_y;
                r1.right=v->m_imgpos_x+v->m_stretchedwidth;
                r1.bottom=v->m_imgpos_y+v->m_stretchedheight;
                FillRect(hdc,&r1,(HBRUSH)GetStockObject(BLACK_BRUSH));
            }

            // paint the background
            ExcludeClipRect(hdc,
                            v->m_imgpos_x, v->m_imgpos_y,
                            v->m_imgpos_x+v->m_stretchedwidth, v->m_imgpos_y+v->m_stretchedheight);

            if(globals.window_bgcolor==TWPNG_WBG_SYSDEFAULT) {
                FillRect(hdc,&v->m_clientrect,GetSysColorBrush(COLOR_WINDOW));
            }
            else {

                if(globals.window_bgcolor==TWPNG_WBG_SAMEASIMAGE && v->m_imghasbgcolor)
                    hbr1 = CreateSolidBrush(v->m_imgbgcolor);
                else
                    hbr1 = CreateSolidBrush(globals.custombgcolor);
                FillRect(hdc,&v->m_clientrect,hbr1);
                DeleteObject(hbr1);
            }
        }
        else {
            FillRect(hdc,&v->m_clientrect,GetSysColorBrush(COLOR_WINDOW));

            if(v->m_errorflag) {
                SetTextColor(hdc,RGB(128,0,0));
                SetBkColor(hdc,RGB(255,255,255));
                SetBkMode(hdc,OPAQUE);
                SelectObject(hdc,GetStockObject(ANSI_VAR_FONT));
                DrawText(hdc,v->m_errormsg,-1,&v->m_clientrect,
                         DT_NOPREFIX|DT_WORDBREAK);
            }
        }

        EndPaint(hwnd, &paintStruct);
        return 0;
    }

    case WM_INITMENU:
    {
        HMENU m;
        m=(HMENU)wParam;
        EnableMenuItem(m,ID_COPYIMAGE,MF_BYCOMMAND|(v->m_dib?MF_ENABLED:MF_GRAYED));
        CheckMenuItem(m,ID_GAMMACORRECT,MF_BYCOMMAND|
                      (globals.use_gamma?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_CORRECTNONSQUARE,MF_BYCOMMAND|
                      (globals.viewer_correct_nonsquare?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_BG_CUSTOM,MF_BYCOMMAND|
                      (globals.use_custombg==1 && globals.use_imagebg==0 ? MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_BG_IMAGEORCUSTOM,MF_BYCOMMAND|
                      (globals.use_custombg && globals.use_imagebg ? MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_BG_STRIPALPHA,MF_BYCOMMAND|
                      (globals.use_custombg==0 && globals.use_imagebg==0 ? MF_CHECKED:MF_UNCHECKED));

        CheckMenuItem(m,ID_WBG_SAMEASIMAGE,MF_BYCOMMAND|
                      (globals.window_bgcolor==TWPNG_WBG_SAMEASIMAGE?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_WBG_SYSDEFAULT,MF_BYCOMMAND|
                      (globals.window_bgcolor==TWPNG_WBG_SYSDEFAULT?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_WBG_CUSTOM,MF_BYCOMMAND|
                      (globals.window_bgcolor==TWPNG_WBG_CUSTOM?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_ZOOM_FIT,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_FIT?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_ZOOM_1_8,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_1_8?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_ZOOM_1_4,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_1_4?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_ZOOM_1_2,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_1_2?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_ZOOM_1,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_1?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_ZOOM_2,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_2?MF_CHECKED:MF_UNCHECKED));
        CheckMenuItem(m,ID_ZOOM_4,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_4?MF_CHECKED:MF_UNCHECKED));
        //CheckMenuItem(m,ID_ZOOM_8,MF_BYCOMMAND|(globals.vsize==TWPNG_VS_8?MF_CHECKED:MF_UNCHECKED));
        return 0;
    }

    case WM_DESTROY:
        twpng_StoreWindowPos(hwnd,&globals.window_prefs.viewer);
        delete g_viewer;
        g_viewer=NULL;
        SetFocus(globals.hwndMain);
        return 0;

    case WM_SIZE:
        GetClientRect(hwnd,&v->m_clientrect);
        if(globals.vsize==TWPNG_VS_FIT) v->CalcStretchedSize();
        return 0;

    case WM_DROPFILES:
        if(globals.dlgs_open<1)
            DroppedFiles((HDROP)wParam);
        return 0;

    case WM_LBUTTONDBLCLK:
        if(globals.vsize==TWPNG_VS_1 || globals.vsize==TWPNG_VS_FIT) {
            if(globals.vsize==TWPNG_VS_1)
                globals.vsize=TWPNG_VS_FIT;
            else
                globals.vsize=TWPNG_VS_1;
            v->CalcStretchedSize();
            InvalidateRect(hwnd,NULL,0);
        }
        return 0;

    case WM_LBUTTONDOWN:
        if(v->m_dragging) return 0;
        if(!v->m_dib) return 0;
        SetCapture(hwnd);
        SetCursor(globals.hcurDrag2);
        pts = MAKEPOINTS(lParam);
        v->m_dragstart_x = v->m_imgpos_x - pts.x;
        v->m_dragstart_y = v->m_imgpos_y - pts.y;
        v->m_dragging = 1;
        return 0;

    case WM_LBUTTONUP:
        SetCapture(NULL);
        v->m_dragging=0;
        return 0;


    case WM_MOUSEMOVE:
        if(v->m_dragging) {
            pts = MAKEPOINTS(lParam);
            v->m_imgpos_x = v->m_dragstart_x + pts.x;
            v->m_imgpos_y = v->m_dragstart_y + pts.y;
            InvalidateRect(hwnd,NULL,TRUE);
        }
        return 0;

    case WM_KEYDOWN:
        if(v->HandleKeyDown(hwnd,wParam,lParam)) {
            return 0;
        }
        break;

    case WM_CLOSE: // The user clicked the [x] for the window.
        globals.autoopen_viewer=0;
        break;  // DefWindowProc will send a WM_DESTROY message

    case WM_COMMAND:
        id=LOWORD(wParam);
        switch(id) {
        case ID_CLOSE:
            globals.autoopen_viewer=0;
            DestroyWindow(hwnd);
            return 0;
        case ID_COPYIMAGE:
            v->CopyImage();
            return 0;
        case ID_GAMMACORRECT:
            globals.use_gamma = !globals.use_gamma;
            v->UpdateViewerWindowTitle();
            update_viewer();
            return 0;
        case ID_CORRECTNONSQUARE:
            globals.viewer_correct_nonsquare = !globals.viewer_correct_nonsquare;
            update_viewer();
            return 0;
        case ID_BG_CUSTOM:
            globals.use_imagebg = 0;
            globals.use_custombg = 1;
            v->UpdateViewerWindowTitle();
            update_viewer();
            return 0;
        case ID_BG_IMAGEORCUSTOM:
            globals.use_imagebg = 1;
            globals.use_custombg = 1;
            v->UpdateViewerWindowTitle();
            update_viewer();
            return 0;
        case ID_BG_STRIPALPHA:
            globals.use_imagebg = 0;
            globals.use_custombg = 0;
            v->UpdateViewerWindowTitle();
            update_viewer();
            return 0;
        case ID_WBG_SAMEASIMAGE:
            globals.window_bgcolor = TWPNG_WBG_SAMEASIMAGE;
            InvalidateRect(hwnd,NULL,0);
            break;
        case ID_WBG_SYSDEFAULT:
            globals.window_bgcolor = TWPNG_WBG_SYSDEFAULT;
            InvalidateRect(hwnd,NULL,0);
            break;
        case ID_WBG_CUSTOM:
            globals.window_bgcolor = TWPNG_WBG_CUSTOM;
            InvalidateRect(hwnd,NULL,0);
            break;

        case ID_SETBG:
        {
            unsigned char tmpr,tmpg,tmpb;
            tmpr=GetRValue(globals.custombgcolor);
            tmpg=GetGValue(globals.custombgcolor);
            tmpb=GetBValue(globals.custombgcolor);
            if(choose_color_dialog(hwnd,&tmpr,&tmpg,&tmpb)) {
                globals.custombgcolor = RGB(tmpr,tmpg,tmpb);
                update_viewer();
            }
            return 0;
        }

        case ID_ZOOM_FIT:
            globals.vsize=TWPNG_VS_FIT;
            goto rezoom;
        case ID_ZOOM_1_8:
            globals.vsize=TWPNG_VS_1_8;
            goto rezoom;
        case ID_ZOOM_1_4:
            globals.vsize=TWPNG_VS_1_4;
            goto rezoom;
        case ID_ZOOM_1_2:
            globals.vsize=TWPNG_VS_1_2;
            goto rezoom;
        case ID_ZOOM_2:
            globals.vsize=TWPNG_VS_2;
            goto rezoom;
        case ID_ZOOM_4:
            globals.vsize=TWPNG_VS_4;
            goto rezoom;
        //case ID_ZOOM_8: globals.vsize=TWPNG_VS_8; goto rezoom;
        case ID_ZOOM_1:
            globals.vsize=TWPNG_VS_1;
rezoom:
            v->CalcStretchedSize();
            InvalidateRect(hwnd,NULL,0);
            break;

        }
    }

exit1:
    return DefWindowProc(hwnd, msg, wParam, lParam);

}
Ejemplo n.º 21
0
LRESULT CALLBACK ProcessListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HBRUSH    hbrBackground;
    int     count;
    RECT    rcItem;
    RECT    rcClip;
    HDC        hDC;
    int        DcSave;

    switch (message)
    {
    case WM_ERASEBKGND:

        /*
         * The list control produces a nasty flicker
         * when the user is resizing the window because
         * it erases the background to white, then
         * paints the list items over it.
         *
         * We will clip the drawing so that it only
         * erases the parts of the list control that
         * show only the background.
         */

        /*
         * Get the device context and save its state
         * to be restored after we're done
         */
        hDC = (HDC) wParam;
        DcSave = SaveDC(hDC);

        /*
         * Get the background brush
         */
        hbrBackground = (HBRUSH) GetClassLongPtrW(hWnd, GCLP_HBRBACKGROUND);

        /*
         * Calculate the clip rect by getting the RECT
         * of the first and last items and adding them up.
         *
         * We also have to get the item's icon RECT and
         * subtract it from our clip rect because we don't
         * use icons in this list control.
         */
        rcClip.left = LVIR_BOUNDS;
        SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM) &rcClip);
        rcItem.left = LVIR_BOUNDS;
        count = SendMessageW(hWnd, LVM_GETITEMCOUNT, 0, 0);
        SendMessageW(hWnd, LVM_GETITEMRECT, count - 1, (LPARAM) &rcItem);

        rcClip.bottom = rcItem.bottom;
        rcItem.left = LVIR_ICON;
        SendMessageW(hWnd, LVM_GETITEMRECT, 0, (LPARAM) &rcItem);
        rcClip.left = rcItem.right;

        /*
         * Now exclude the clip rect
         */
        ExcludeClipRect(hDC, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom);

        /*
         * Now erase the background
         *
         *
         * FIXME: Should I erase it myself or
         * pass down the updated HDC and let
         * the default handler do it?
         */
        GetClientRect(hWnd, &rcItem);
        FillRect(hDC, &rcItem, hbrBackground);

        /*
         * Now restore the DC state that we
         * saved earlier
         */
        RestoreDC(hDC, DcSave);
        
        return TRUE;
    }

    /*
     * We pass on all messages except WM_ERASEBKGND
     */
    return CallWindowProcW(OldProcessListWndProc, hWnd, message, wParam, lParam);
}
Ejemplo n.º 22
0
void PaintStatus(HDC hDC, PRECT pRect, PRECT pWholeWindow) {
	extern BOOL  SizeGrip;
	static POINT Line[3][2];
	static POINT InnerFrame[2][3];
	INT    i;
	HPEN   OldPen;
	HFONT  OldFont;
	RECT   Background;

	if (!StatusHeight) return;
	Background.left   = pRect->left;
	Background.top	  = pWholeWindow->bottom - StatusHeight + 2;
	Background.right  = pRect->right;
	Background.bottom = pWholeWindow->bottom;
	FillRect(hDC, &Background, FaceBrush);
	if (StatusFont) OldFont = SelectObject(hDC, StatusFont);
	SetBkMode(hDC, TRANSPARENT);
	Line[0][0].y = Line[0][1].y = pWholeWindow->bottom - StatusHeight;
	Line[1][0].y = Line[1][1].y = pWholeWindow->bottom - StatusHeight + 1;
	Line[2][0].y = Line[2][1].y = pWholeWindow->bottom - 1;
	Line[0][1].x = Line[1][1].x = Line[2][1].x = pRect->right;
	OldPen = SelectObject(hDC, ShadowPen);
	Polyline(hDC, Line[0], 2);
	SelectObject(hDC, HilitePen);
	Polyline(hDC, Line[1], 2);
#	if defined(LOWERSHADOW)
		if (WinVersion <= 0x351) {
			SelectObject(hDC, ShadowPen);
			Polyline(hDC, Line[2], 2);
		}
#	endif
	if (SizeGrip) {
		static POINT Offsets[6] = {{-2,-1}, {-1,-2}, {-1,-3}, {-4,0},
								   {-4,-1},  {0,-5}};
		POINT		 HiliteShadow[6];

		for (i=0; i<6; ++i) {
			HiliteShadow[i].x = Offsets[i].x + ClientRect.right;
			HiliteShadow[i].y = Offsets[i].y + ClientRect.bottom;
			if (WinVersion < MAKEWORD(95,3) || !SizeGrip) {
				HiliteShadow[i].x -= 2;
				HiliteShadow[i].y -= 2;
			}
		}
		for (i=0; i<3; ++i) {
			INT j;

			SelectObject(hDC, ShadowPen);
			Polyline(hDC, HiliteShadow, 4);
			SelectObject(hDC, HilitePen);
			Polyline(hDC, HiliteShadow+4, 2);
			for (j=0; j<6; ++j) {
				if ((j&3)==0 || (j&3)==3) HiliteShadow[j].x -= 5;
				else					  HiliteShadow[j].y -= 5;
			}
		}
	}
	for (i=6; i>=0; --i) {
		PWSTR Text;

		if (StatusFields[i].x >= pRect->right) continue;
		if (StatusFields[i].x + StatusFields[i].Width < pRect->left) continue;
		StatusFields[i].TextExtent = 0;
		if (!StatusFields[i].Width) continue;
		if (StatusStyle[StatusFields[i].Style].LoweredFrame) {
			InnerFrame[0][0].x = InnerFrame[0][1].x = InnerFrame[1][0].x
				= StatusFields[i].x;
			InnerFrame[0][2].x = InnerFrame[1][1].x = InnerFrame[1][2].x
				= StatusFields[i].x + StatusFields[i].Width;
			InnerFrame[0][0].y = InnerFrame[1][0].y = InnerFrame[1][1].y
				= ClientRect.bottom -
				  (WinVersion>=MAKEWORD(95,3) && SizeGrip ? 1 : 3);
			InnerFrame[0][1].y = InnerFrame[0][2].y = InnerFrame[1][2].y
				= ClientRect.bottom - StatusHeight + 4;
			SelectObject(hDC, HilitePen);
			Polyline(hDC, InnerFrame[1], 3);
			++InnerFrame[0][2].x;
			SelectObject(hDC, ShadowPen);
			Polyline(hDC, InnerFrame[0], 3);
		}
		if ((Text = StatusFields[i].Text) != NULL && *Text) {
			INT  x, y, Len;
			SIZE Size;

			Len = wcslen(Text);
			x = StatusFields[i].x + 3;
			ExcludeClipRect(hDC,
							StatusFields[i].x + StatusFields[i].Width,
							ClientRect.bottom - StatusHeight + 1,
							ClientRect.right,
							ClientRect.bottom);
			if (StatusFields[i].Centered) {
				INT c = (StatusFields[i].Width - StatusWidth(Text)) >> 1;

				if (c > 0) x += c;
			}
			y = ClientRect.bottom - StatusHeight + 5;
			SetTextColor(hDC, StatusStyle[StatusFields[i].Style].Color);
			TextOutW(hDC, x, y, Text, Len);
			StatusFields[i].TextExtent =
				GetTextExtentPointW(hDC, Text, Len, &Size) ? Size.cx : 0;
		}
Ejemplo n.º 23
0
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	TRichUtil *ru;

	EnterCriticalSection(&csRich);
	ru = li.List_Find(&sListInt, (TRichUtil*)&hwnd);
	LeaveCriticalSection(&csRich);

	if (ru == NULL) return 0;

	switch(msg) 
	{
		case WM_CHAR:
		{
			HWND hwndMsg = GetDlgItem(GetParent(hwnd), IDC_MESSAGE);
			if (hwndMsg != hwnd)
			{
				SetFocus(hwndMsg);
				SendMessage(hwndMsg, WM_CHAR, wParam, lParam);
			}
			break;
		}
		
		case WM_THEMECHANGED:
		case WM_STYLECHANGED:
		{
			RichUtil_ClearUglyBorder(ru);
			break;
		}

		case WM_NCPAINT:
		{
			LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
			if (ru->hasUglyBorder && MyIsThemeActive()) 
			{
				HANDLE hTheme = MyOpenThemeData(ru->hwnd, L"EDIT");
				if (hTheme) 
				{
					RECT rcBorder;
					RECT rcClient;
					int nState;
					HDC hdc = GetWindowDC(ru->hwnd);
					LONG style = GetWindowLong(hwnd, GWL_STYLE);

					GetWindowRect(hwnd, &rcBorder);
					rcBorder.right -= rcBorder.left; rcBorder.bottom -= rcBorder.top;
					rcBorder.left = rcBorder.top = 0;
					CopyRect(&rcClient, &rcBorder);
					rcClient.left += ru->rect.left;
					rcClient.top += ru->rect.top;
					rcClient.right -= ru->rect.right;
					rcClient.bottom -= ru->rect.bottom;
					ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);

					if (MyIsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
						MyDrawThemeParentBackground(hwnd, hdc, &rcBorder);

					if (style & WS_DISABLED)
						nState = ETS_DISABLED;
					else if (style & ES_READONLY)
						nState = ETS_READONLY;
					else 
						nState = ETS_NORMAL;

					MyDrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL);
					MyCloseThemeData(hTheme);
					ReleaseDC(hwnd, hdc);
					return 0;
				}
			}
			return ret;
		}
		case WM_NCCALCSIZE:
		{
			LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
			NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
			
			if (ru->hasUglyBorder && MyIsThemeActive()) 
			{
				HANDLE hTheme = MyOpenThemeData(hwnd, L"EDIT");

				if (hTheme) 
				{
					RECT rcClient ={0}; 
					HDC hdc = GetDC(GetParent(hwnd));

					if (MyGetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) 
					{
						ru->rect.left = rcClient.left-ncsParam->rgrc[0].left;
						ru->rect.top = rcClient.top-ncsParam->rgrc[0].top;
						ru->rect.right = ncsParam->rgrc[0].right-rcClient.right;
						ru->rect.bottom = ncsParam->rgrc[0].bottom-rcClient.bottom;
						ncsParam->rgrc[0] = rcClient;

						MyCloseThemeData(hTheme);
						ReleaseDC(GetParent(hwnd), hdc);
						return WVR_REDRAW;
					}
					ReleaseDC(GetParent(hwnd), hdc);
					MyCloseThemeData(hTheme);
				}
			}
			return ret;
		}

		case WM_ENABLE:
			RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
			break;

		case WM_GETDLGCODE:
			return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam) & ~DLGC_HASSETSEL;

		case WM_NCDESTROY:
		{
			LRESULT ret = CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);

			if (IsWindow(hwnd)) 
			{
				if((WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC) == &RichUtil_Proc)
					SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ru->origProc);
			}

			EnterCriticalSection(&csRich);
			li.List_RemovePtr(&sListInt, ru);
			LeaveCriticalSection(&csRich);

			mir_free(ru);
			return ret;
		}
	}
	return CallWindowProc(ru->origProc, hwnd, msg, wParam, lParam);
}
Ejemplo n.º 24
0
void clipper_t::cut(int x, int y, int w, int h)
{
	ExcludeClipRect(hdc, x, y, x+w, y+h);
}
Ejemplo n.º 25
0
void HexView::DrawNoteStrip(HDC hdc, int nx, int ny, BOOKNODE *bnp)
{
	BOOKMARK *bookmark = &bnp->bookmark;

	RECT rect = { nx, ny, nx+300, ny+50 };
	RECT clip;
	const int colWidth = 18;

	HANDLE hOldBr  = SelectObject(hdc, GetStockObject(DC_BRUSH));
	HANDLE hOldPen = SelectObject(hdc, GetStockObject(DC_PEN));

	COLORREF colBG		= RGB(245,245,245);
	COLORREF colShadow	= RGB(220,220,220);//GetSysColor(COLOR_3DFACE);
	COLORREF colLine	= GetSysColor(COLOR_3DSHADOW);

	BookmarkRect(bookmark, &rect);

	//
	// [x] Close button 
	//
	//	Do this first so we can mask it out of the way; prevents flickering
	//
	CloseButton(hdc, &rect, &clip, m_HitTestHot == HVHT_BOOKCLOSE && m_HighlightHot == bnp);
	ExcludeClipRect(hdc, clip.left, clip.top, clip.right, clip.bottom);


	//
	// Main rectangle - dark border with light fill
	//
	RoundRect(hdc, &rect, 2, 2, colLine, colBG);

	// vertical separator line 
	MoveToEx(hdc, rect.left + colWidth, rect.top, 0);
	LineTo(hdc, rect.left + colWidth, rect.bottom);

	// color panel
	RECT colrc = { rect.left + 1, rect.top + 1, rect.left + colWidth, rect.bottom - 1 };
	SetBkColor(hdc, bookmark->backcol);
	ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &colrc, 0, 0, 0);

	RECT textrc = 
	{ 
		rect.left + colWidth + 8, rect.top + 4, rect.right - 4, rect.bottom - 4 
	};

	SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
	SetBkColor(hdc, colBG);
	SetTextAlign(hdc, TA_LEFT|TA_TOP);

	BOOL fItalic = FALSE;

	TCHAR *pszTitle = bookmark->pszTitle;
	TCHAR *pszText  = bookmark->pszText;

	if(pszTitle == 0 && pszText == 0)
	{
		fItalic	  = TRUE;
		pszTitle  = TEXT("Enter Bookmark");
		pszText   = TEXT("Descriptive text here");
	}
	
	HANDLE hOld;

	Arse();

	if(pszTitle)
	{
		// the text
		TCHAR text1[100];
		wsprintf(text1, _T("%08X - %d bytes"), bookmark->offset, bookmark->length);

		//hOld=SelectObject(hdc, hFont1);
		MoveToEx(hdc, textrc.left, textrc.top, 0);

		textrc.right -= 32;
		
		// draw the offset/length
		SetTextColor(hdc, GetSysColor(COLOR_3DDKSHADOW));
		hOld=SelectObject(hdc, hFont2);
		int height = DrawText(hdc, text1, lstrlen(text1), &textrc, DT_SINGLELINE|DT_RIGHT|DT_TOP|DT_NOPREFIX|DT_WORDBREAK|DT_MODIFYSTRING);//DT_NOCLIP|DT_LEFT|DT_WORDBREAK);
		SelectObject(hdc, hOld);

		// draw the title, left-aligned
		SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
		hOld=SelectObject(hdc, fItalic?hFont3:hFont1);
		height = DrawText(hdc, pszTitle, lstrlen(pszTitle), &textrc, DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_WORDBREAK|DT_MODIFYSTRING);//DT_NOCLIP|DT_LEFT|DT_WORDBREAK);
		SelectObject(hdc, hOld);
		
		textrc.top += height;
	}

	if(pszText)
	{
		MoveToEx(hdc, textrc.left, textrc.top, 0);
		hOld = SelectObject(hdc, fItalic ? hFont3 : hFont2);
		DrawText(hdc, pszText, lstrlen(pszText), &textrc, DT_LEFT|DT_TOP|DT_NOPREFIX|DT_WORDBREAK|DT_MODIFYSTRING);//DT_NOCLIP|DT_LEFT|DT_WORDBREAK);
		SelectObject(hdc, hOld);
	}

	DeleteObject(hFont1);
	DeleteObject(hFont2);
	DeleteObject(hFont3);

	// sizing grip
	SizingGrip(hdc, &rect, 0);//, hPen);


	//
	//	Mask the rectangle
	//
/*	HRGN hClipRgn = CreateRoundRectRgn(&rect, 2, 2);
	ExtSelectClipRgn(hdc, hClipRgn, RGN_DIFF);

	//
	// Shadow goes underneath (offset by 2 pixels), so gets drawn first
	//
	OffsetRect(&rect, SHADOW_DEPTH, SHADOW_DEPTH);
	RoundRect(hdc, &rect, 2, 2, colShadow, colShadow);

	OffsetRgn(hClipRgn, SHADOW_DEPTH, SHADOW_DEPTH);
	ExtSelectClipRgn(hdc, hClipRgn, RGN_DIFF);
	DeleteObject(hClipRgn);*/

	//OffsetRect(&rect, -SHADOW_DEPTH, -SHADOW_DEPTH);


	// Include the shadow
	rect.right += SHADOW_DEPTH;
	rect.bottom += SHADOW_DEPTH;
	//RoundRect(hdc, smeg.left, smeg.top, smeg.right, smeg.bottom);
	ExcludeClipRect(hdc, rect.left, rect.top, rect.right, rect.bottom);

	SelectObject(hdc, hOldPen);
	SelectObject(hdc, hOldBr);

}
Ejemplo n.º 26
0
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	TRichUtil *ru = NULL, tru;
	int idx;
	LRESULT ret;

	tru.hwnd = hwnd;
	{
		mir_cslock lck(csRich);
		if (List_GetIndex(&sListInt, &tru, &idx))
			ru = (TRichUtil *)sListInt.items[idx];
	}

	switch (msg) {
	case WM_THEMECHANGED:
	case WM_STYLECHANGED:
		RichUtil_ClearUglyBorder(ru);
		break;

	case WM_NCPAINT:
		ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
		if (ru->hasUglyBorder && IsThemeActive())
		{
			HANDLE hTheme = OpenThemeData(ru->hwnd, L"EDIT");

			if (hTheme) {
				RECT rcBorder;
				RECT rcClient;
				int nState;
				HDC hdc = GetWindowDC(ru->hwnd);

				GetWindowRect(hwnd, &rcBorder);
				rcBorder.right -= rcBorder.left; rcBorder.bottom -= rcBorder.top;
				rcBorder.left = rcBorder.top = 0;
				CopyRect(&rcClient, &rcBorder);
				rcClient.left += ru->rect.left;
				rcClient.top += ru->rect.top;
				rcClient.right -= ru->rect.right;
				rcClient.bottom -= ru->rect.bottom;
				ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);

				if (IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
					DrawThemeParentBackground(hwnd, hdc, &rcBorder);

				if (!IsWindowEnabled(hwnd))
					nState = ETS_DISABLED;
				else if (SendMessage(hwnd, EM_GETOPTIONS, 0, 0) & ECO_READONLY)
					nState = ETS_READONLY;
				else nState = ETS_NORMAL;

				DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL);
				CloseThemeData(hTheme);
				ReleaseDC(hwnd, hdc);
				return 0;
			}
		}
		return ret;

	case WM_NCCALCSIZE:
		{
			ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
			NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS *)lParam;

			if (ru->hasUglyBorder && IsThemeActive()) {
				HANDLE hTheme = OpenThemeData(hwnd, L"EDIT");
				if (hTheme) {
					RECT rcClient = {0};
					HDC hdc = GetDC(GetParent(hwnd));

					if (GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) {
						ru->rect.left = rcClient.left - ncsParam->rgrc[0].left;
						ru->rect.top = rcClient.top - ncsParam->rgrc[0].top;
						ru->rect.right = ncsParam->rgrc[0].right - rcClient.right;
						ru->rect.bottom = ncsParam->rgrc[0].bottom - rcClient.bottom;
						ncsParam->rgrc[0] = rcClient;

						CloseThemeData(hTheme);
						ReleaseDC(GetParent(hwnd), hdc);
						return WVR_REDRAW;
					}
					ReleaseDC(GetParent(hwnd), hdc);
					CloseThemeData(hTheme);
				}
			}
		}
		return ret;

	case WM_ENABLE:
		RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
		break;

	case WM_GETDLGCODE:
		return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam) & ~DLGC_HASSETSEL;

	case WM_NCDESTROY:
		ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
		{
			mir_cslock lck(csRich);
			List_Remove(&sListInt, idx);
		}
		mir_free(ru);
		return ret;
	}
	return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
}
Ejemplo n.º 27
0
void CardButton::Clip(HDC hdc)
{
    if(fVisible == false) return;

    ExcludeClipRect(hdc, rect.left,  rect.top, rect.right, rect.bottom);
}
Ejemplo n.º 28
0
void CardButton::Draw(HDC hdc, bool fNormal)
{
    SIZE textsize;
    int x, y;        //text x, y
    int ix, iy;        //icon x, y
    int iconwidth = 0;

    RECT cliprect;

    if(fVisible == 0) return;

    if(hFont == 0)
        SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
    else
        SelectObject(hdc, hFont);

    GetTextExtentPoint32(hdc, szText, lstrlen(szText), &textsize);

    if(hIcon)
    {
        x = rect.left + 32 + 8;
    }
    else
    {
        if(uStyle & CB_ALIGN_LEFT)
        {
            x = rect.left + iconwidth;
        }
        else if(uStyle & CB_ALIGN_RIGHT)
        {
            x = rect.left + (rect.right-rect.left-iconwidth-textsize.cx);
        }
        else    //centered
        {
            x = rect.right - rect.left - iconwidth;
            x = (x - textsize.cx) / 2;
            x += rect.left + iconwidth;
        }
    }

    y = rect.bottom - rect.top;
    y = (y - textsize.cy) / 2;
    y += rect.top;

    //calc icon position..
    ix = rect.left + 4;
    iy = rect.top + (rect.bottom-rect.top-32) / 2;

    //if button is pressed, then shift text
    if(fNormal == false && (uStyle & CB_PUSHBUTTON))
    {
        x += 1;
        y += 1;
        ix += 1;
        iy += 1;
    }

    SetRect(&cliprect, x, y, x+textsize.cx, y+textsize.cy);
    ExcludeClipRect(hdc, x, y, x+textsize.cx, y+textsize.cy);

    //
    //    Calc icon pos
    //

    if(hIcon)
    {
        ExcludeClipRect(hdc, ix, iy, ix + 32, iy + 32);
    }

    if(uStyle & CB_PUSHBUTTON)
    {
        DrawRect(hdc, &rect, fNormal);

        SetBkColor(hdc,   MAKE_PALETTERGB(crBack));
        SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));

        SelectClipRgn(hdc, 0);

        ExtTextOut(hdc, x, y, ETO_OPAQUE, &cliprect, szText, lstrlen(szText), 0);
    }
    else
    {
        SetBkColor(hdc,      MAKE_PALETTERGB(crBack));
        SetTextColor(hdc, crText);//MAKE_PALETTERGB(crText));

        SelectClipRgn(hdc, 0);

        ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0);
    }

    if(hIcon)
    {
        HBRUSH hbr = CreateSolidBrush(MAKE_PALETTERGB(crBack));
        DrawIconEx(hdc, ix, iy, hIcon, 32, 32, 0, hbr, 0);
        DeleteObject(hbr);
    }

}
Ejemplo n.º 29
0
BOOL TooltipOnNotify(LRESULT *plRes, LPARAM lParam)
{
	if (!hwndTooltip || hwndTooltip != ((LPNMHDR)lParam)->hwndFrom) return FALSE;
	switch (((LPNMHDR)lParam)->code)
	{
		case NM_CUSTOMDRAW:
			if (bTooltipCustomDrawDisable) break;
			if (((LPNMCUSTOMDRAW)lParam)->dwDrawStage == CDDS_PREPAINT)
			{
				if (((LPNMCUSTOMDRAW)lParam)->rc.top)
				{
					RECT rc;
					TooltipUpdate(((LPNMCUSTOMDRAW)lParam)->hdc, &((LPNMCUSTOMDRAW)lParam)->rc, &rc, ((LPNMTTCUSTOMDRAW)lParam)->uDrawFlags);
					ExcludeClipRect(((LPNMCUSTOMDRAW)lParam)->hdc, rc.left, rc.top, rc.right, rc.bottom);
				}
				else
				{
					ExcludeClipRect(((LPNMCUSTOMDRAW)lParam)->hdc, ((LPNMCUSTOMDRAW)lParam)->rc.left, ((LPNMCUSTOMDRAW)lParam)->rc.top, ((LPNMCUSTOMDRAW)lParam)->rc.right, ((LPNMCUSTOMDRAW)lParam)->rc.bottom);
				}
				*plRes = CDRF_NOTIFYPOSTPAINT;
				return TRUE;
			}
			if (((LPNMCUSTOMDRAW)lParam)->dwDrawStage == CDDS_POSTPAINT)
			{
				HRGN hrgn = CreateRectRgn(((LPNMCUSTOMDRAW)lParam)->rc.left, ((LPNMCUSTOMDRAW)lParam)->rc.top, ((LPNMCUSTOMDRAW)lParam)->rc.right, ((LPNMCUSTOMDRAW)lParam)->rc.bottom);
				if (hrgn)
				{
					ExtSelectClipRgn(((LPNMCUSTOMDRAW)lParam)->hdc, hrgn, RGN_OR);
					DeleteObject(hrgn);
				}
				*plRes = 0;
				return TRUE;
			}
			break;
		case TTN_NEEDTEXTW:
			if (!bTooltipShow || !bTooltipUpdated)
			{
				TooltipUpdateText();
				TooltipUpdateTitle();
			}
			MultiByteToWideChar(CP_ACP, 0, formatTooltip, -1,
				formatTooltipW, sizeof(formatTooltipW)/sizeof(WCHAR));
			((LPTOOLTIPTEXTW)lParam)->lpszText = formatTooltipW;
			*plRes = 0;
			//if (!formatTooltipW[0] && bVista) 
			//	PostMessage(hwndClock, CLOCKM_VISTATOOLTIP, 1, 0);
			return TRUE;
		case TTN_NEEDTEXT:
			if (!bTooltipShow || !bTooltipUpdated)
			{
				TooltipUpdateText();
				TooltipUpdateTitle();
			}
			((LPTOOLTIPTEXT)lParam)->lpszText = formatTooltip;
			*plRes = 0;
			//if (!formatTooltip[0] && bVista) 
			//	PostMessage(hwndClock, CLOCKM_VISTATOOLTIP, 1, 0);
			return TRUE;
		case TTN_SHOW:
			if (!bTooltipShow)
			{
				TooltipUpdateText();
				TooltipUpdateTitle();
				SetWindowPos(hwndTooltip, HWND_TOPMOST, 0, 0, 0, 0,
					SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
				bTooltipShow = TRUE;
			}
			break;
		case TTN_POP:
			bTooltipShow = FALSE;
			bTooltipUpdated = FALSE;
			break;
	}
	return FALSE;
}
Ejemplo n.º 30
0
static LRESULT CALLBACK RichUtil_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	TRichUtil *ru;

	EnterCriticalSection(&csRich);
	ru = rlist_find(slist, hwnd);
	LeaveCriticalSection(&csRich);
	switch(msg) {
	case WM_THEMECHANGED:
	case WM_STYLECHANGED:
		RichUtil_ClearUglyBorder(ru);
		break;

	case WM_NCPAINT:
		{
			LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
			if (ru->hasUglyBorder && IsThemeActive()) {
				HANDLE hTheme = OpenThemeData(ru->hwnd, L"EDIT");

				if (hTheme) {
					RECT rcBorder;
					RECT rcClient;
					int nState;
					HDC hdc = GetWindowDC(ru->hwnd);

					GetWindowRect(hwnd, &rcBorder);
					rcBorder.right -= rcBorder.left; rcBorder.bottom -= rcBorder.top;
					rcBorder.left = rcBorder.top = 0;
					CopyRect(&rcClient, &rcBorder);
					rcClient.left += ru->rect.left;
					rcClient.top += ru->rect.top;
					rcClient.right -= ru->rect.right;
					rcClient.bottom -= ru->rect.bottom;
					ExcludeClipRect(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
					if(IsThemeBackgroundPartiallyTransparent(hTheme, EP_EDITTEXT, ETS_NORMAL))
						DrawThemeParentBackground(hwnd, hdc, &rcBorder);
					if (!IsWindowEnabled(hwnd))
						nState = ETS_DISABLED;
					else if(SendMessage(hwnd, EM_GETOPTIONS, 0, 0) & ECO_READONLY)
						nState = ETS_READONLY;
					else nState = ETS_NORMAL;
					DrawThemeBackground(hTheme, hdc, EP_EDITTEXT, nState, &rcBorder, NULL);
					CloseThemeData(hTheme);
					ReleaseDC(hwnd, hdc);
					return 0;
				}
			}
			return ret;
		}
	case WM_NCCALCSIZE:
		{
			LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
			NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;

			if (ru->hasUglyBorder && IsThemeActive()) {
				HANDLE hTheme = OpenThemeData(hwnd, L"EDIT");

				if (hTheme) {
					RECT rcClient; 
					HDC hdc = GetDC(GetParent(hwnd));

					ZeroMemory(&rcClient, sizeof(RECT));
					if(GetThemeBackgroundContentRect(hTheme, hdc, EP_EDITTEXT, ETS_NORMAL, &ncsParam->rgrc[0], &rcClient) == S_OK) {
						ru->rect.left = rcClient.left-ncsParam->rgrc[0].left;
						ru->rect.top = rcClient.top-ncsParam->rgrc[0].top;
						ru->rect.right = ncsParam->rgrc[0].right-rcClient.right;
						ru->rect.bottom = ncsParam->rgrc[0].bottom-rcClient.bottom;
						CopyRect(&ncsParam->rgrc[0], &rcClient);
						CloseThemeData(hTheme);
						ReleaseDC(GetParent(hwnd), hdc);
						return WVR_REDRAW;
					}
					ReleaseDC(GetParent(hwnd), hdc);
					CloseThemeData(hTheme);
				}
			}
			return ret;
		}

	case WM_ENABLE:
		RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
		break;

	case WM_DESTROY:
		{
			LRESULT ret = mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
			EnterCriticalSection(&csRich);
			slist = rlist_remove(slist, ru);
			LeaveCriticalSection(&csRich);
			if (ru) free(ru);
			return ret;
		}
	}
	return mir_callNextSubclass(hwnd, RichUtil_Proc, msg, wParam, lParam);
}