示例#1
0
void AxWidget::OnRender( XGraphics& graphic, const Rect& rcUpdate )
{
	if (!IsVisible() || m_pContainer == NULL) 
		return;

	RECT rcControl = Rect(rcUpdate).GetRectStruct();
	m_pContainer->OnRender(graphic.GetDC(), rcControl);
}
示例#2
0
void ProgressBar::OnRender(XGraphics &graphic, const Rect &rcUpdate)
{
	Rect rect(Point(0,0), GetSize());
	Rect rcClip(0,0,0,0);
	int x, w, m;
	
	if (m_pBkImage && m_pBkImage->IsValid())
	{
		w = m_pBkImage->GetWidth() / 3;
		
		rcClip.SetRect(0, 0, w, m_pBkImage->GetHeight());
		RECT rc = rcClip.GetRectStruct();
		graphic.DrawImage(m_pBkImage, 0, 0, -1, -1, &rc);
		
		m = rect.GetRight() - w;
		for (x = w; x < m ; x += w)
		{
			rcClip.SetRect(x, 0, x + w, m_pBkImage->GetHeight());
			rc = rcClip.GetRectStruct();
			graphic.DrawImage(m_pBkImage, x - w, 0, -1, -1, &rc);
		}
		
		rcClip.SetRect(m, 0, m + w, m_pBkImage->GetHeight());
		rc = rcClip.GetRectStruct();
		graphic.DrawImage(m_pBkImage, m - 2 * w, 0, -1, -1, &rc);
	}
	
	if (m_pBarImage && m_pBarImage->IsValid() && m_nMax != m_nMin && m_nPosition > m_nMin)
	{
		w = m_pBarImage->GetWidth() / 3;
		int nPos = 2 * w + (rect.GetRight() - 2 * w) * (m_nPosition - m_nMin) / (m_nMax - m_nMin);

		rcClip.SetRect(0, 0, w, m_pBarImage->GetHeight());
		RECT rc = rcClip.GetRectStruct();
		graphic.DrawImage(m_pBarImage, 0, 0, -1, -1, &rc);

		m = nPos - w;
		for (x = w; x < m ; x += w)
		{
			rcClip.SetRect(x, 0, x + w, m_pBarImage->GetHeight());
			rc = rcClip.GetRectStruct();
			graphic.DrawImage(m_pBarImage, x - w, 0, -1, -1, &rc);
		}

		rcClip.SetRect(m, 0, m + w, m_pBarImage->GetHeight());
		rc = rcClip.GetRectStruct();
		graphic.DrawImage(m_pBarImage, m - 2 * w, 0, -1, -1, &rc);
	}
}
示例#3
0
XBOOL XHScrollBar::OnPaint(XGraphics &g)
{
	XRect rect;
	GetClientRect(rect);
	XColor c(XWindow::m_nColors[XCW_BUTTON]);
	XColor cc(c);
	cc.Bright(24);
	g.SetBackColor(cc);
	g.FillRectangle(rect);
	
	XRect r=rect;
	int pp;
	CalcRect(r,pp);
	if(m_nStatus==XS_UPPAGE&&r.left>rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(0,0,r.left,rect.bottom));
	}
	if(m_nStatus==XS_DOWNPAGE&&r.right<rect.right-rect.bottom)
	{
	   XColor cm(c);
	   cm.Bright(12);
	   g.SetBackColor(cm);
	   g.FillRectangle(XRect(r.right,0,rect.right-rect.bottom,rect.bottom));
	}


	XColor hc(c);
	hc.Bright(10);
	XRect rl(0,0,rect.bottom,rect.bottom);
	XRect rr(rect.right-rect.bottom,0,rect.right,rect.bottom);
	g.DrawButton(rl,m_nStatus==XS_UPLINE?hc:c,XBS_BFRAME|XBS_WFRAME);
	g.DrawButton(rr,m_nStatus==XS_DOWNLINE?hc:c,XBS_BFRAME|XBS_WFRAME);

	cc=c;cc.Dark(60);
	g.DrawDirect(rl,XK_LEFT,cc);
	g.DrawDirect(rr,XK_RIGHT,cc);


	g.DrawButton(r,m_nStatus==XS_HAND?hc:c,XBS_BFRAME|XBS_WFRAME|XBS_VHAND);

	return XTRUE;
	//*/
}
示例#4
0
XBOOL XToolBar::OnPaint(XGraphics &g)
{   
	//return XTRUE;
   if(m_pBack==XNULL) return XTRUE;
   //XRect rect=m_clip;
   //int mx,my;
   //g.GetOrigin(mx,my);
   //g.SetOrigin(mx+rect.left,my+rect.top);
  // rect-=rect.TopLeft();
   int x,w=m_pBack->Width();
   XRect rect(0,0,w,m_pBack->Height());
   //rect.right=m_pBack->Width();
   for(x=0;x<m_clip.right;x+=w)
   {
	   if(x+w<m_clip.left) continue;
	   XPoint dt(x,0);
	   if(rect.right+x>m_clip.right)
		   rect.right=m_clip.right-x;
		   //rect.right=m_nWidth-x;
	   g.DrawImage(*m_pBack,dt,rect);
   }


   int dw=m_nItemWidth,ddh=m_pBack->Height();
   int il=0,ir=1,im=0,llx=m_nItemLeft*dw,rrx=m_rect.Width()-m_nItemRight*dw;

   for(int i=0;i<m_nItemCount;i++)
	{
		//int ix=CommandToPos(iCommand);
	    XRect irect;
		XPoint dt(0,0);
		XImage*pImage=&m_normal;
		switch(m_items[i].iStatus)
		{
		case XTS_NORMAL:
			 pImage=&m_normal;break;
		case XTS_DISABLE:
			 if(!m_gray.IsEmpty())
				pImage=&m_gray;
			 break;
		//case XTS_CHECKED:
		//	 pImage=&m_check;break;
		case XTS_ACTIVE:
			 if(!m_active.IsEmpty())
			 pImage=&m_active;break;
		}
		if(m_items[i].iImage==TICON_SLIDER)
		{			
			im+=SLIDER_WIDTH;
			XImage*pImageBut=pImage;
			if(m_items[i].iPos<=0&&!m_gray.IsEmpty())
				pImageBut=&m_gray;
			else if(m_items[i].iStatus==XTS_ACTIVE1&&!m_active.IsEmpty())
				pImageBut=&m_active;
			if(pImageBut&&!pImageBut->IsEmpty())
			{
				int dh=pImage->Height();
				dt.y=(ddh-dh+1)>>1;
				dt.x=(im-SLIDER_WIDTH+1)*dw+dt.y+12;
				irect.left=TICON_ZOOMIN*dh;
				irect.right=irect.left+dh;
				irect.top=0;
				irect.bottom=dh;
				XRect rtt(dt.x,dt.y,dt.x+irect.Width(),dt.y+irect.Height());
				dt.x+=(m_nItemWidth-ddh)>>1;
				rtt&=m_clip;
				if(!rtt.IsRectEmpty())
					g.DrawImage(*pImageBut,dt,irect);
			}
			pImageBut=pImage;
			if(m_items[i].iPos>=100&&!m_gray.IsEmpty())
				pImageBut=&m_gray;
			else if(m_items[i].iStatus==XTS_ACTIVE2&&!m_active.IsEmpty())
				pImageBut=&m_active;
			if(pImageBut&&!pImageBut->IsEmpty())
			{
				int dh=pImage->Height();
				dt.x=(im)*dw+dt.y;
				irect.left=TICON_ZOOMOUT*dh;
				irect.right=irect.left+dh;
				irect.top=0;
				irect.bottom=dh;
				XRect rtt(dt.x,dt.y,dt.x+irect.Width(),dt.y+irect.Height());
				dt.x+=(m_nItemWidth-ddh)>>1;
				rtt&=m_clip;
				if(!rtt.IsRectEmpty())
					g.DrawImage(*pImageBut,dt,irect);
			}