Esempio n. 1
0
   LRESULT CPanel::OnPaint(UINT, WPARAM,LPARAM,BOOL&)
   {
      CPaintDC dc(m_hWnd); 
      CRect r;
      GetClientRect(&r);
      
      CRgn rgn;
      HRGN oldRgn=NULL;
      if(roundCorners)
      {
          rgn.CreateRoundRectRgn(r.left,r.top,r.right,r.bottom,cornerParam.x,cornerParam.y);
          dc.SelectClipRgn(rgn);
      }

      if(m_hTheme == NULL || theme == FALSE)
      {
          if(enableGradient==FALSE)
            dc.FillSolidRect(&r,bkColor);
          else
            gradientRender.DrawGradient(dc,r,startColor,endColor,gradientType,transformationType);
      }
      else
        DrawThemeBackground(dc,TABP_BODY,0,&r,NULL);
        //DrawThemeBackground(dc,BP_PUSHBUTTON,0,&r,NULL);
      
      if(!caption.IsEmpty())
      {
         CFont oldFont=dc.SelectFont(font);
         COLORREF tc=dc.SetTextColor(textColor);
         int bkm=dc.SetBkMode(TRANSPARENT);
         dc.DrawText(caption,caption.GetLength(),r,vertAlign|horizAlign|singleLine);
         dc.SetTextColor(tc);
         dc.SetBkMode(bkm);
         dc.SelectFont(oldFont);
      }
      if(m_hTheme == NULL || theme == FALSE)
      {
          if(roundCorners==FALSE)
          {
            dc.DrawEdge(&r,inner|outer,edge);
          }
          else
          {
              dc.SelectClipRgn(NULL);
              CPen pen;
              HBRUSH oldBrush = dc.SelectStockBrush(NULL_BRUSH);
              pen.CreatePen(PS_INSIDEFRAME,1,borderColor);
              HPEN oldpen=dc.SelectPen(pen);
              dc.RoundRect(r,cornerParam);
              dc.SelectPen(oldpen);
              dc.SelectBrush(oldBrush);
          }
      }
      else
          DrawThemeEdge(dc,TABP_BODY,0,&r,inner|outer,edge);
          //DrawThemeEdge(dc,BP_PUSHBUTTON,0,&r,inner|outer,edge);

      return 0;
   }
Esempio n. 2
0
/********************************************
DrawEdge
	Purpose
		Provides a more straightforward way to draw the edge by wrapping all the calls required into the dll,
		as well as using our theme data mappings to find the core info required.
	Params
		hwnd  - the HWND of the control we draw to, or NUL
		hdc   - the device context for the dll to draw to
		type  - the cell type we want to draw
		state - the state of the cell we want to draw
		pRect - represents the area we want to draw to
		uEdge - specifies the type of inner and outer edges to draw. 
			This parameter must be a combination of one inner-border flag and one outer-border flag, 
			or one of the combination flags.
		uFlags - specifies the type of border to draw.
		pContentRect - is exposed, but is almost always NULL
	Return
		A  bool to indicate success or failure, which is used to control drawing in the old style throughout the library
*********************************************/
bool UGXPThemes::DrawEdge(HWND hwnd, HDC hdc, UGXPCellType type, UGXPThemeState state, 
			const RECT *pRect, UINT uEdge, UINT uFlags, RECT *pContentRect)
{
	bool success = false;

	if (useThemes)
	{
		UGThemeData * td = LookupThemeData(type, state);

		if (!td)
		{
			return false;
		}

		HANDLE hTheme = OpenThemeData(hwnd, td->GetThemeName());

		short edgeFormat =  (uEdge & UG_BDR_RAISED) ? BDR_RAISEDINNER | BDR_SUNKENOUTER : BDR_SUNKENINNER | BDR_RAISEDOUTER;

		if(hTheme)
		{
			success = SUCCEEDED(DrawThemeEdge(hTheme, hdc, td->GetPartID(), td->GetStateID(), pRect, edgeFormat, uFlags, pContentRect));

			// We populate pContentRect with the rect to draw content in.
			if (success && pContentRect)
			{
				*pContentRect = *pRect;
				// Because the grid draws itself multiple times, this was causing areas 
				// to become undrawn.  May need some investigation, may just be unnecessary.
/*
				// 3602 = TMT_CONTENTMARGINS
				XPMARGINS margins;
				if (SUCCEEDED(UGXPThemes::GetThemeMargins(hTheme, hdc, td->GetPartID(), td->GetStateID(), 3602, const_cast<RECT*>(pRect), &margins)))
				{
					*pContentRect = *pRect;
					pContentRect->bottom -= margins.cyBottomHeight;
					pContentRect->right -= margins.cxRightWidth;
					pContentRect->top += margins.cyTopHeight;
					pContentRect->left += margins.cxLeftWidth;
				}*/
			}
	//		CloseThemeData(hTheme);
		}
	}
	
	return success;
}
Esempio n. 3
0
bool UGXPThemes::DrawEdge(HWND hwnd, HDC hdc, LPCWSTR theme, int partID, int stateID, 
		const RECT *pRect, UINT uEdge, UINT uFlags, RECT *pContentRect)
{
	bool success = false;

	if (useThemes)
	{
		HANDLE themeHandle = OpenThemeData(hwnd, theme);

		if (themeHandle)
		{
			HRESULT hr = DrawThemeEdge(themeHandle, hdc, partID, stateID, pRect, uEdge, uFlags, pContentRect);
			success = SUCCEEDED(hr);
		}
	}

	return success;

}