void CControlUI::DoPaint(HDC hDC, const RECT& rcPaint) { if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return; // »æÖÆÑÐò£º±³¾°ÑÕÉ«->±³¾°Í¼->״̬ͼ->Îı¾->±ß¿ò SIZE cxyBorderRound = GetManager()->GetDPIObj()->Scale(m_cxyBorderRound); RECT rcBorderSize = GetManager()->GetDPIObj()->Scale(m_rcBorderSize); if( cxyBorderRound.cx > 0 || cxyBorderRound.cy > 0 ) { CRenderClip roundClip; CRenderClip::GenerateRoundClip(hDC, m_rcPaint, m_rcItem, cxyBorderRound.cx, cxyBorderRound.cy, roundClip); PaintBkColor(hDC); PaintBkImage(hDC); PaintStatusImage(hDC); PaintForeColor(hDC); PaintForeImage(hDC); PaintText(hDC); PaintBorder(hDC); } else { PaintBkColor(hDC); PaintBkImage(hDC); PaintStatusImage(hDC); PaintForeColor(hDC); PaintForeImage(hDC); PaintText(hDC); PaintBorder(hDC); } }
void CControlUI::DoPaint(HDC hDC, const RECT& rcPaint) { if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return; // »æÖÆÑÐò£º±³¾°ÑÕÉ«->±³¾°Í¼->״̬ͼ->Îı¾->±ß¿ò if( m_cxyBorderRound.cx > 0 || m_cxyBorderRound.cy > 0 ) { CRenderClip roundClip; CRenderClip::GenerateRoundClip(hDC, m_rcPaint, m_rcItem, m_cxyBorderRound.cx, m_cxyBorderRound.cy, roundClip); PaintBkColor(hDC); PaintBkImage(hDC); PaintStatusImage(hDC); PaintForeColor(hDC); PaintForeImage(hDC); PaintText(hDC); PaintBorder(hDC); } else { PaintBkColor(hDC); PaintBkImage(hDC); PaintStatusImage(hDC); PaintForeColor(hDC); PaintForeImage(hDC); PaintText(hDC); PaintBorder(hDC); } }
// /// Paint the text gadget by painting gadget borders, & then painting text in /// the InnerRect. Empty or 0 text blanks the gadget. // /// Calls TGadget::PaintBorder to paint the border. Calls TGadget::GetInnerRect to /// calculate the area of the text gadget's rectangle. If the text is left-aligned, /// Paint calls dc.GetTextExtent to compute the width and height of a line of the /// text. To set the background color, Paint calls dc.GetSysColor and sets the /// default background color to face shading (COLOR_BTNFACE). To set the button text /// color, Paint calls dc.SetTextColor and sets the default button text color to /// COLOR_BTNTEXT. To draw the text, Paint calls dc.ExtTextOut and passes the /// parameters ETO_CLIPPED (so the text is clipped to fit the rectangle) and /// ETO_OPAQUE (so the rectangle is filled with the current background color). // void TTextGadget::Paint(TDC& dc) { PaintBorder(dc); TRect innerRect; GetInnerRect(innerRect); if (!Font) dc.SelectObject(GetGadgetWindow()->GetFont()); else dc.SelectObject(*Font); TColor textColor = GetEnabledColor(); if(!GetEnabled()) textColor = TColor::Sys3dHilight; bool transparent = GetGadgetWindow()->GetFlatStyle() & TGadgetWindow::FlatXPTheme; if(!Text){ if (!transparent) { TColor color = dc.SetBkColor(TColor::Sys3dFace); dc.ExtTextOut(0,0, ETO_OPAQUE, &innerRect, _T(""), 0); dc.SetBkColor(color); } } else { // Create a UI Face object for this button & let it paint the button face // uint align[] = {DT_LEFT, DT_CENTER, DT_RIGHT}; uint format = DT_SINGLELINE | DT_VCENTER | align[Align]; TUIFace face(innerRect, Text, BkgndColor, format); TPoint dstPt(innerRect.TopLeft()); dc.SetBkColor(BkgndColor); TColor oldTxColor = dc.SetTextColor(textColor); if (!GetEnabled()) face.Paint(dc, dstPt, TUIFace::Disabled, false, !transparent); else face.Paint(dc, dstPt, TUIFace::Normal, false, !transparent); dc.SetTextColor(oldTxColor); } dc.RestoreFont(); }
// /// Calls TGadget::PaintBorder to perform the actual painting of the border of the /// control. Get Inner rectangle of control, layout Text and Bitmap and call /// PaintText() and PaintFace(). // void TButtonTextGadget::Paint(TDC& dc) { PRECONDITION(Window); PaintBorder(dc); TRect faceRect, textRect, btnRect; GetInnerRect(faceRect); Layout(faceRect, textRect, btnRect); if(Style&sText) PaintText(dc, textRect, Text); if(Style&sBitmap) PaintFace(dc, btnRect); }
XBOOL XDomTD::Paint(DRAWCONTEXT *pDraw,XU32 nData) { if(m_nWidth<=0) return 0; XRect rect(m_nPosX+pDraw->SPACING,m_nPosY+pDraw->SPACING, m_nPosX+m_nWidth-1,m_nPosY+m_nHeight-1); if(pDraw->bCollapse) rect.InflateRect(2,2); if(rect.IsUnion(pDraw->paint)) { // pDraw->Save(); // XRect ra(m_nPosX,m_nPosY,m_nPosX if(pDraw->bCollapse) { rect.DeflateRect(1,1); /*rect.InflateRect(1,1); rect.top--; rect.left--; rect.right++; rect.bottom++;*/ } PaintBack(pDraw,rect); // rect.InflateRect(1,1); XDomNode::Handle(XDO_PAINT,(XU32)pDraw,0); if(pDraw->TABBORDER) { XColor color(pDraw->DCBACK); color.Dark(30); XU32 nColor=pDraw->pDraw->SetColor(color); pDraw->pDraw->FrameRectangle(rect); pDraw->pDraw->SetColor(nColor); } if(pDraw->bCollapse) { //rect.top--; rect.right++; //rect.bottom++; } PaintBorder(pDraw,rect); //if(bSet) // pDraw->Restore(); return XTRUE; } return XFALSE; }
XU32 XHTMLBody::Handle(XU32 nOpera, XU32 pData1, XU32 pData2) { XU32 i; switch(nOpera) { //case XDO_SET_START: // return StartEvent((DRAWCONTEXT*)pData1); /*case XDO_LAYEROUT_CELLS: { CELLDATA*p=(CELLDATA*)pData2; DRAWCONTEXT*pd=(DRAWCONTEXT*)pData1; XU32 ss=PreLayerout(pd,p); XDomCard::Handle(nOpera,pData1,pData2); EndLayerout(pd,p); }return 1;*/ case XDO_LAYEROUT_CELL: { CELLDATA data; LAYEROUTDATA margin; //data.Reset(pData->cur.x,pData->cur.y,XTRUE); CELLDATA*pData=&data;//(CELLDATA*)pData2; DRAWCONTEXT*pDraw=(DRAWCONTEXT*)pData1; pDraw->Init(); pData->Reset(pDraw->win.left,pDraw->win.top,XTRUE); PreLayerout(pDraw,pData,&margin); if(m_nWidth>0) { if(margin.nMargin[BORDERDATA::LEFT]>0&& margin.nMargin[BORDERDATA::LEFT]+m_nWidth>pDraw->view.Width()) { margin.nMargin[BORDERDATA::LEFT]=XMAX( (pDraw->view.Width()-m_nWidth)>>1,0); } if(m_nWidth>pDraw->win.Width()) pDraw->win.right=pDraw->win.left+m_nWidth; } //pData->Init(); InitMargin(pDraw,pData,&margin,m_nPosX,m_nPosY,m_nWidth,m_nHeight); XPoint pt=pData->cur; for(i=0;i<m_childs.GetSize();i++) m_childs[i]->LayeroutItem(pDraw,pData,XTRUE);//Handle(XDO_LAYEROUT_CELLS,(XU32)pDraw,(XU32)&data); pData->Reset(pt.x,pt.y,XFALSE); NewRow(0,pDraw,pData,pDraw->IND); pData->bEmpty=XTRUE; for(i=0;i<m_childs.GetSize();i++) m_childs[i]->LayeroutItem(pDraw,pData,XFALSE);//Handle(XDO_LAYEROUT_CELL,(XU32)pDraw,(XU32)&data); //data.max.cx-=pData->cur.x; //data.max.cy-=pData->cur.y; m_nWidth=pData->max.cx-pt.x; m_nHeight=pData->max.cy-pt.y; if(m_nWidth<pDraw->view.Width()) m_nWidth=pDraw->view.Width(); if(m_nHeight<pDraw->view.Height()) m_nHeight=pDraw->view.Height(); XSize size(m_nWidth,m_nHeight); SetMargin(&margin,m_nWidth,m_nHeight,size); //m_nWidth=data.max.cx-pData->cur.x; pData=(CELLDATA*)pData2; SetRowSize(pDraw,pData,size,m_nWidth,XFALSE); NewRow(0,pDraw,pData,pDraw->IND); /*CELLDATA*p=(CELLDATA*)pData2; DRAWCONTEXT*pd=(DRAWCONTEXT*)pData1; LAYEROUTDATA margin; XU32 ss=PreLayerout(pd,p,margin); // StartMargin(pd,p,XTRUE); //BeginMargin(pd,p); m_nPosX=p->cur.x; m_nPosY=p->cur.y; XDomCard::Handle(nOpera,pData1,pData2); EndLayerout(pd,p); m_nWidth=XMAX(p->max.cx-m_nPosX,pd->view.Width()-(m_nPosX<<1)-1); m_nHeight=XMAX(p->max.cy-m_nPosY,pd->view.Height()-(m_nPosY<<1)-1);*/ }return 1; case XDO_PAINT: { XRect rect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight); PaintBack((DRAWCONTEXT*)pData1,rect); XU32 s=XDomCard::Handle(nOpera,pData1,pData2); PaintBorder((DRAWCONTEXT*)pData1,rect); return s; }; case XDO_EVENT_ONTIMER: { XRect rect(0,0,m_nWidth,m_nHeight); return OnTimer((XEVENTDATA*)pData1,rect)| XDomCard::Handle(nOpera,pData1,pData2); }break; /* case XDO_SET_ATTR: case XDO_ADD_ATTR: SetBodyAttrib((XVar*)pData1); break; */ //return XTRUE; }
XU32 XDomTable::Paint(DRAWCONTEXT *pDraw) { //XString8 str=FindAttrib(XEAB::ID,""); //if(str=="last") // int a=0; if(m_nWidth<=0) return 0; if(m_nPosX>=pDraw->paint.right|| m_nPosX+m_nWidth<=pDraw->paint.left|| m_nPosY>=pDraw->paint.bottom|| m_nPosY+m_nHeight<=pDraw->paint.top) return 0; XU32 ss=PrePaint(pDraw); XRect rect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight); int bd=FindAttrib(XEAB::BORDER,0); XU8 nType=FindAttrib(XEAB::FRAME,XEnumFrame::BOX); XU8 bCollapse=pDraw->bCollapse; pDraw->bCollapse=FindAttrib(XEAB::BORDER_COLLAPSE,0); int nr=pDraw->SPACING; pDraw->SPACING=XMAX(FindAttrib(XEAB::CELLSPACING,1),0); XU8 d=pDraw->TABBORDER; pDraw->TABBORDER=bd; XRect ar=XRect(rect.left,rect.top,rect.right,rect.bottom); PaintBack(pDraw,ar,XTRUE); XU32 s=HandleChild(XDO_PAINT_TABLE,(XU32)pDraw,0); pDraw->bCollapse=bCollapse; pDraw->TABBORDER=d; if(nType==XEF::VOID_X) bd=0; if(bd>0) { XGraphics*pg=pDraw->pDraw; //pDraw->Save(); XColor cc(pDraw->DCBACK); XColor dc(cc); dc.Dark(60); cc.Dark(30); int bx=m_nPosX,by=m_nPosY; int ex=m_nPosX+m_nWidth-1,ey=m_nPosY+m_nHeight-1; for(int i=0;i<bd;i++) { pg->SetColor(cc); switch(nType) { case XEF::BOX: case XEF::ABOVE: case XEF::BORDER: case XEF::HSIDES: pg->DrawLine(bx,by,ex,by); break; } switch(nType) { case XEF::BORDER: case XEF::BOX: case XEF::VSIDES: case XEF::LHS: pg->DrawLine(bx,by,bx,ey); break; } pg->SetColor(dc); switch(nType) { case XEF::BORDER: case XEF::BOX: case XEF::VSIDES: case XEF::RHS: pg->DrawLine(ex,by,ex,ey); break; } switch(nType) { case XEF::BORDER: case XEF::BOX: case XEF::HSIDES: case XEF::BELOW: pg->DrawLine(bx,ey,ex,ey); break; } cc.Bright(3); dc.Bright(3); bx++; by++; ex--; ey--; } //cc.Dark(20); /*pDraw->pDraw->DrawFrame( XRect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight), cc,bd,XTRUE);*/ // pDraw->Restore(); } pDraw->SPACING=nr; PaintBorder(pDraw,ar); EndPaint(pDraw); //if(bSave) // pDraw->Restore(); return s; }
// Paint the client area of the window and resize the child window controls void Paint() { // Sizes used in the layout int margin = 16; int labelwidth = 70; int buttonwidth = 80; int taskheight = 122; int buttonheight = 25; int statusheight = 54; // Rectangular sizes in the client area sizeitem client; sizeitem label1, label2, label3; sizeitem border1, border2, border3; sizeitem tasks, status, errors; sizeitem clear, task, start, stop, reset; // Find the width and height of the client area RECT rectangle; GetClientRect(Handle.window, &rectangle); client.set(rectangle); // 0 when the window is minimized // Tasks label label1.set(margin, margin, labelwidth, taskheight); // Tasks box border1 = label1; border1.x(label1.r() + margin); border1.r(client.w() - margin); // Measure from right, and keep it wide enough if (border1.w() < buttonwidth) border1.w(buttonwidth); // Clear button clear = border1; clear.y(border1.b() + margin); clear.w(buttonwidth); clear.h(buttonheight); // Buttons in that row task = clear; task.addx(buttonwidth + margin); start = task; start.addx(buttonwidth + margin); stop = start; stop.addx(buttonwidth + margin); reset = stop; reset.addx(buttonwidth + margin); // Labels on the left label2 = label1; label2.y(clear.b() + margin); label2.h(statusheight); label3 = label2; label3.y(label2.b() + margin); label3.b(client.b() - margin); // Measure from bottom, and keep it tall enough if (label3.h() < buttonheight) label3.h(buttonheight); // Controls on the right border2 = label2; border2.x(border1.x()); border2.w(border1.w()); border3 = label3; border3.x(border1.x()); border3.w(border1.w()); // Controls in borders; tasks = border1; tasks.inside(); status = border2; status.inside(); errors = border3; errors.inside(); // Move labels inside to line up with controls label1.inside(); label2.inside(); label3.inside(); // Pick colors for the background banner message brushitem *field, *text, *label; if (Handle.display.banner == L"start") { field = &Handle.blue; text = &Handle.lightblue; label = &Handle.white; } else if (Handle.display.banner == L"running") { field = &Handle.yellow; text = &Handle.lightyellow; label = &Handle.black; } else if (Handle.display.banner == L"done") { field = &Handle.green; text = &Handle.lightgreen; label = &Handle.black; } else if (Handle.display.banner == L"errors") { field = &Handle.red; text = &Handle.lightred; label = &Handle.white; } else { field = &Handle.blue; text = &Handle.lightblue; label = &Handle.white; } // Position and size child window controls WindowSize(Handle.tasks, tasks); WindowSize(Handle.status, status); WindowSize(Handle.errors, errors); WindowSize(Handle.clear, clear); WindowSize(Handle.task, task); WindowSize(Handle.start, start); WindowSize(Handle.stop, stop); WindowSize(Handle.reset, reset); // Paint the window deviceitem device; device.OpenPaint(Handle.window); // Paint the background color PaintFill(&device, client, field->brush); // Paint the banner device.Font(Handle.arial); device.FontColor(text->color); device.BackgroundColor(field->color); PaintText(&device, Handle.display.banner, client); // Paint the text lables on the left device.Font(Handle.font); device.FontColor(label->color); device.Background(TRANSPARENT); PaintText(&device, L"Tasks", label1); PaintText(&device, L"Status", label2); PaintText(&device, L"Errors", label3); // Paint the borders PaintBorder(&device, border1, Handle.middle.brush); PaintBorder(&device, border2, Handle.middle.brush); PaintBorder(&device, border3, Handle.middle.brush); }