/*------------------------------------------------------------------------*/ VOID DrawGrid(WINDOWINFO *pwi, RECTL *rcl) { POINTL ptl; LONG lForeColor; LONG lBackColor; ULONG ulcx = pwi->ulgridcx; ULONG ulcy = pwi->ulgridcy; lForeColor = GpiQueryColor(pwi->hps); lBackColor = GpiQueryBackColor(pwi->hps); if (view.iZoom == 2) { ulcx /=2; ulcy /=2; } else if (view.iZoom && view.iZoom != 2) { ulcx *= view.iZoom; ulcy *= view.iZoom; ulcx /= 100; ulcy /= 100; } GpiSetColor(pwi->hps,lBackColor); GpiSetMix(pwi->hps,FM_INVERT); for (ptl.x= rcl->xLeft; ptl.x < rcl->xRight; ptl.x += (ulcx * pwi->ulgriddisp)) for (ptl.y=rcl->yBottom; ptl.y < rcl->yTop; ptl.y += (ulcy * pwi->ulgriddisp)) { GpiMove(pwi->hps,&ptl); GpiLine(pwi->hps,&ptl); } GpiSetColor(pwi->hps,lForeColor); }
/************************************************************************** * * Name : DlgQuatro(*HPS phps,int i, int j, LONG lColor) * * Description: рисует квадратик в любом месте любого цвета * * Concepts: Родной брат обычного квадратика. Необходимость * в нем возникла при разработке диалога. Старый не * подходил, и переделывать его значило бы * перелопачивать всю программу. Елки-палки. * * Parameters : phps - указатель на hps * i,j - координаты * lColor - цвет *************************************************************************/ VOID DlgQuatro(PHPS phps,int i, int j, LONG lColor) { RECTL rec;//где рисовать POINTL ptl;//куда и откуда рисовать //рисуем квадрат rec.xLeft = j+1; rec.xRight = j+bs; rec.yBottom = i; rec.yTop = i+bs-1; WinFillRect(*phps, &rec, lColor); if(st){//рисуем линии 3D if(lColor>6) GpiSetColor(*phps,CLR_DARKGRAY); else GpiSetColor(*phps,lColor+8); ptl.x=j; ptl.y=i; GpiMove(*phps,&ptl); ptl.x=j+bs-1; GpiLine(*phps,&ptl); GpiMove(*phps,&ptl); ptl.y=i+bs; GpiLine(*phps,&ptl); ptl.x=j+bs-2; ptl.y=i+bs-1; GpiMove(*phps,&ptl); ptl.y=i+1; GpiLine(*phps,&ptl); GpiMove(*phps,&ptl); ptl.x=j+1; GpiLine(*phps,&ptl);} } /* End of DlgQuatro */
/************************************************************************** * * Name : Quatro(*HPS phps,int i, int j) * * Description: рисует квадратик * * Concepts: Получает указатель на пространство отображения * и рисует квадрат размером BmpSize с координатами * i и j * * * API's : * * Parameters : phps - указатель на hps * i,j - номера элемента матрицы Field *************************************************************************/ VOID Quatro(PHPS phps,int i, int j) { RECTL rec;//где рисовать POINTL ptl;//куда и откуда рисовать //рисуем квадрат if(Field == NULL) return;//если инициализации не было rec.xLeft = j*BmpSize+1; rec.xRight = j*BmpSize+BmpSize; rec.yBottom = i*BmpSize; rec.yTop = i*BmpSize+BmpSize-1; WinFillRect(*phps, &rec, Field[i][j]); if(bStyle){//рисуем линии 3D if(Field[i][j]>6) GpiSetColor(*phps,CLR_DARKGRAY); else GpiSetColor(*phps,Field[i][j]+8); ptl.x=j*BmpSize; ptl.y=i*BmpSize; GpiMove(*phps,&ptl); ptl.x=j*BmpSize+BmpSize-1; GpiLine(*phps,&ptl); GpiMove(*phps,&ptl); ptl.y=i*BmpSize+BmpSize; GpiLine(*phps,&ptl); ptl.x=j*BmpSize+BmpSize-2; ptl.y=i*BmpSize+BmpSize-1; GpiMove(*phps,&ptl); ptl.y=i*BmpSize+1; GpiLine(*phps,&ptl); GpiMove(*phps,&ptl); ptl.x=j*BmpSize+1; GpiLine(*phps,&ptl);} } /* End of Quatro */
void drawAxis(HPS hps,long yAxis12Dx,long yAxis12Dy,long yAxis22Dx,long yAxis22Dy,long xAxis12Dx,long xAxis12Dy,long xAxis22Dx,long xAxis22Dy,long zAxis12Dx,long zAxis12Dy,long zAxis22Dx,long zAxis22Dy,int drawIt ) { POINTL p; if (drawIt ) GpiSetColor (hps,CLR_GREEN ); else GpiSetColor (hps,CLR_BLACK ); p.x=yAxis12Dx; p.y=yAxis12Dy; GpiMove(hps,&p); p.x=yAxis22Dx; p.y=yAxis22Dy; GpiLine(hps,&p); p.x=xAxis12Dx; p.y=xAxis12Dy; GpiMove(hps,&p); p.x=xAxis22Dx; p.y=xAxis22Dy; GpiLine(hps,&p); p.x=zAxis12Dx; p.y=zAxis12Dy; GpiMove(hps,&p); p.x=zAxis22Dx; p.y=zAxis22Dy; GpiLine(hps,&p); }
VOID ClientPaint(HWND hwnd) { POINTL pt; HPS hps; RECTL rcl; LONG lLen; LONG lCenter; WinInvalidateRect(hwnd,(PRECTL)NULL,FALSE); hps = WinBeginPaint(hwnd,(HPS)NULL,&rcl ); // if (bShowingProgress) // rcl.yBottom = 60L; WinFillRect(hps,&rcl,CLR_WHITE); lCenter = (INITWIDTH / 2); if (bDebug) { GpiSetBackColor(hps,CLR_WHITE); GpiSetBackMix(hps,BM_OVERPAINT); GpiCreateLogFont(hps,NULL,3,&fattMsgFont); GpiSetColor(hps,CLR_BLACK); GpiSetCharSet(hps,3); pt.x = 10; if (szDebugLineOne[0] != 0) { pt.y = 82L; GpiCharStringAt(hps,&pt,strlen(szDebugLineOne),szDebugLineOne); } if (szDebugLineTwo[0] != 0) { pt.y = 62L; GpiCharStringAt(hps,&pt,strlen(szDebugLineTwo),szDebugLineTwo); } } else { GpiSetColor(hps,CLR_CYAN); GpiSetBackColor(hps,CLR_WHITE); GpiSetBackMix(hps,BM_OVERPAINT); GpiCreateLogFont(hps, NULL, 2, &fattBigFont); GpiSetCharSet(hps,2); pt.x = (lCenter - (10 * stBigCell.cx)); pt.y = 60L; GpiCharStringAt(hps,&pt,21,"OS/tools Installation"); } if (!bShowingProgress) PrintBanners(szBannerOne,szBannerTwo); WinEndPaint(hps); }
static HPS hpsDrawText(HPS hPS, PTEXTFIELD ptf) { FONTMETRICS fm3D; /* Font Metrics Holder */ RECTL rcl; /* Rectangle Holder */ register LONG i, k, n; /* String Length Counter */ /* Get the presentation space for the control */ /* and set the colour table to RGB mode */ GpiCreateLogColorTable(hPS, 0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL); /* Check to see if any text present and if the */ /* case, draw it within the rectangle */ if ( ptf->cText ) /* Check to see if the text is to be broken over */ /* more than one line if the length of the text */ /* is greater than the width of the control */ if ( ptf->flStyle & DT_WORDBREAK ) { /* Word break style specified, set the drawing */ /* of the text within a loop such that it can */ /* be drawn on successive lines */ n = ptf->cText; GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &fm3D); rcl = ptf->rcl; i = 0; do { n -= (k = WinDrawText(hPS, n, &ptf->pszText[i], &rcl, ptf->lClrText, ptf->lClrBackground, ptf->flFormat)); i += k; if ( (rcl.yTop -= fm3D.lMaxBaselineExt) < rcl.yBottom ) break; } while ( n > 0 ); } else WinDrawText(hPS, ptf->cText, ptf->pszText, &ptf->rcl, ptf->lClrText, ptf->lClrBackground, ptf->flFormat); else WinFillRect(hPS, &ptf->rcl, ptf->lClrBackground); GpiSetColor(hPS, ptf->lClrLeftTop); GpiMove(hPS, &ptf->aptl[3]); GpiPolyLine(hPS, 2L, ptf->aptl); GpiSetColor(hPS, ptf->lClrBottomRight); GpiPolyLine(hPS, 2L, &ptf->aptl[2]); return(hPS); }
void drawGrid(HPS hps,long gridX,long gridY,int drawIt,char *str,BOOL tracename) { POINTL p; if (!tracename) return; if (drawIt ) GpiSetColor (hps,CLR_CYAN ); else GpiSetColor (hps,CLR_BLACK ); p.x=gridX-10; p.y=gridY-10; GpiMove(hps,&p); p.x=gridX-13; p.y=gridY-9; GpiLine(hps,&p); p.x=gridX-13; p.y=gridY+9; GpiLine(hps,&p); p.x=gridX-10; p.y=gridY+10; GpiLine(hps,&p); p.x=gridX+10; p.y=gridY-10; GpiMove(hps,&p); p.x=gridX+13; p.y=gridY-9; GpiLine(hps,&p); p.x=gridX+13; p.y=gridY+9; GpiLine(hps,&p); p.x=gridX+10; p.y=gridY+10; GpiLine(hps,&p); p.x=gridX; p.y=gridY-15; if (drawIt ) GpiSetColor (hps,CLR_WHITE ); GpiCharStringAt(hps,&p,strlen(str),str); }
/*-------------------------------------------------- * Draws the 3D border *-------------------------------------------------*/ void PMWindow::draw_3dborder( HPS ps, const SHAPE& rect, long thickness ) { LONG palette_format; if( !GpiQueryColorData( ps, 1, &palette_format )) PM_THROW_GUIERROR(); LONG white = palette_format == LCOLF_RGB ? RGB_WHITE : CLR_WHITE; LONG darkgray = palette_format == LCOLF_RGB ? RGB_DARKGRAY : CLR_DARKGRAY; LONG palegray = palette_format == LCOLF_RGB ? RGB_PALEGRAY : CLR_PALEGRAY; LONG black = palette_format == LCOLF_RGB ? RGB_BLACK : CLR_BLACK; POINTL pos; GpiSetLineWidth( ps, LINEWIDTH_NORMAL ); pos.y = rect.y; pos.x = rect.x; GpiMove( ps, &pos ); GpiSetColor( ps, white ); pos.x = rect.x+rect.cx-1; GpiLine( ps, &pos ); pos.y = rect.y+rect.cy-1; GpiLine( ps, &pos ); GpiSetColor( ps, darkgray ); pos.x = rect.x; GpiLine( ps, &pos ); pos.y = rect.y; GpiLine( ps, &pos ); if( thickness > 1 ) { pos.y = rect.y+1; pos.x = rect.x+1; GpiMove( ps, &pos ); GpiSetColor( ps, palegray ); pos.x = rect.x+rect.cx-2; GpiLine( ps, &pos ); pos.y = rect.y+rect.cy-2; GpiLine( ps, &pos ); GpiSetColor( ps, black ); pos.x = rect.x+1; GpiLine( ps, &pos ); pos.y = rect.y+1; GpiLine( ps, &pos ); } }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static INT cxClient, cyClient ; static LONG alJoin [] = { LINEJOIN_BEVEL, LINEJOIN_ROUND, LINEJOIN_MITRE }, alEnd [] = { LINEEND_FLAT, LINEEND_SQUARE, LINEEND_ROUND } ; HPS hps ; INT i ; switch (msg) { case WM_SIZE: cxClient = SHORT1FROMMP (mp2) ; cyClient = SHORT2FROMMP (mp2) ; return 0 ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ; GpiErase (hps) ; for (i = 0 ; i < 3 ; i++) { // Draw the geometric line GpiSetLineJoin (hps, alJoin [i]) ; GpiSetLineEnd (hps, alEnd [i]) ; GpiSetLineWidthGeom (hps, cxClient / 20) ; GpiSetColor (hps, CLR_DARKGRAY) ; GpiBeginPath (hps, 1) ; DrawFigure (hps, i, cxClient, cyClient) ; GpiEndPath (hps) ; GpiStrokePath (hps, 1, 0) ; // Draw the cosmetic line GpiSetLineWidth (hps, LINEWIDTH_THICK) ; GpiSetColor (hps, CLR_BLACK) ; DrawFigure (hps, i, cxClient, cyClient) ; } WinEndPaint (hps) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
int icqskin_drawImage(HPS hps, PRECTL rcl, HBITMAP image, HBITMAP mask) { POINTL aptl[4]; BITMAPINFOHEADER bmpData; int x,y; GpiQueryBitmapParameters(image, &bmpData); x = ((rcl->xRight - rcl->xLeft)/2) - (bmpData.cx/2); y = ((rcl->yTop - rcl->yBottom)/2) - (bmpData.cy/2); aptl[0].x = x+rcl->xLeft; aptl[0].y = y+rcl->yBottom; aptl[1].x = (aptl[0].x+bmpData.cx)-1; aptl[1].y = (aptl[0].y+bmpData.cy)-1; aptl[2].x = aptl[2].y = 0; aptl[3].x = bmpData.cx; aptl[3].y = bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, mask, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); return bmpData.cy; }
VOID ShowStatusLine( const HPS hps, const char Moves, const char Ships, const LONG Width, const LONG Height ) { RECTL Rect = { 0, Height, Width, Height + 30 }; POINTL Point = { Width, Height }; CHAR text[256]; WinFillRect( hps, &Rect, CLR_WHITE ); //SYSCLR_WINDOW ); // clear background GpiSetColor( hps, CLR_BLACK ); GpiSetLineType( hps, LINETYPE_SHORTDASH ); GpiSetLineWidth( hps, LINEWIDTH_NORMAL ); GpiSetMix( hps, FM_OVERPAINT ); GpiMove( hps, &Point ); Point.x = 0; GpiLine( hps, &Point ); Point.x += 10; Point.y += 10; GpiMove( hps, &Point ); if( Ships ) sprintf( text, "%d %s made %d %s still lost", Moves, Moves == 1 ? "move" : "moves", Ships, Ships == 1 ? "ship" : "ships" ); else sprintf( text, "%d %s made All ships found", Moves, Moves == 1 ? "move" : "moves" ); GpiCharString( hps, strlen(text), text ); DosSleep( 1 ); // free time slice }
/*------------------------------------------------------------------------*/ void DrawLineSegment(HPS hps, WINDOWINFO *pwi, POBJECT pObj, RECTL *prcl) { POINTL ptl1; POINTL ptl2; pLines pLin; pLin = (pLines)pObj; GpiSetMix(hps,FM_DEFAULT); if (pwi->usdrawlayer == pLin->bt.usLayer) { ptl1.x = (LONG)(pLin->ptl1.x * pwi->usFormWidth ); ptl1.y = (LONG)(pLin->ptl1.y * pwi->usFormHeight); ptl1.x +=(LONG)pwi->fOffx; ptl1.y +=(LONG)pwi->fOffy; ptl2.x = (LONG)(pLin->ptl2.x * pwi->usFormWidth ); ptl2.y = (LONG)(pLin->ptl2.y * pwi->usFormHeight); ptl2.x +=(LONG)pwi->fOffx; ptl2.y +=(LONG)pwi->fOffy; if (pLin->bt.Shade.lShadeType != SHADE_NONE) lineShadow(pLin,hps,pwi,ptl1,ptl2); GpiSetLineType(hps,pLin->bt.line.LineType); GpiSetColor(hps,pLin->bt.line.LineColor); drawLine(pLin,hps,pwi,ptl1,ptl2); } /*layer stuff */ }
/************************************************************************** * * Name : InitClientArea() * * Description: Prepares the client area to accept the images * * Concepts : Called once by the Init() routine * - obtain a window device context * - define the image presentation space * - associate the two * - set foreground/background colours & * background mix for the presentation space * * API's : WinOpenWindowDC * GpiCreatePS * GpiSetColor * GpiSetBackColor * GpiSetBackMix * * Parameters : hwnd = client window handle * * Return : TRUE - client area successfully set up * FALSE - client area setup failed * *************************************************************************/ BOOL InitClientArea(HWND hwnd) { SIZEL sizl; sizl.cx = 0L; /* set size to default for device */ sizl.cy = 0L; /* (full screen) */ vhdc = WinOpenWindowDC(hwnd); if (!vhdc) return FALSE; vhps = GpiCreatePS(vhab, vhdc, &sizl, (ULONG)PU_PELS | GPIT_NORMAL | GPIA_ASSOC ); if (!vhps) return FALSE; GpiSetColor(vhps, vlForeClr); GpiSetBackColor(vhps, vlBackClr); GpiSetBackMix(vhps, BM_OVERPAINT); return TRUE; } /* End of InitClientArea */
MRESULT DrawMenuItem( POWNERITEM poi ) { TASKDATA* data = (TASKDATA*)poi->hItem; BOOL select = (poi->fsAttribute & MIA_HILITED) ? TRUE : FALSE; ULONG cx_icon = WinQuerySysValue( HWND_DESKTOP, SV_CXICON ); ULONG cy_icon = WinQuerySysValue( HWND_DESKTOP, SV_CYICON ); POINTL pos; RECTL rect = poi->rclItem; WinFillRect( poi->hps, &rect, select ? SYSCLR_MENUHILITEBGND : SYSCLR_MENU ); rect.xLeft += 2; rect.yBottom += ( rect.yTop - rect.yBottom - cy_icon/2 ) / 2; if( data->hIcon != NULLHANDLE ) { WinDrawPointer( poi->hps, rect.xLeft + 1, rect.yBottom + 1, data->hIcon, DP_MINI ); } rect.xLeft += cx_icon/2 + 5; rect.yBottom = poi->rclItem.yBottom; WinDrawText( poi->hps, -1, data->szTitle, &rect, select ? SYSCLR_MENUHILITE : SYSCLR_MENUTEXT, 0, DT_LEFT | DT_VCENTER ); // Well well well... And now ;) we are going to fix A great-Warp4-Menu-Bug // Make to redraw erased parts of menu's window border // Define something like #ifdef WARP_3 if you are running OS/2 Warp 3.x // vertical "light" line pos.x = poi->rclItem.xLeft; pos.y = 1; GpiSetColor( poi->hps, SYSCLR_BUTTONLIGHT ); GpiMove( poi->hps, &pos ); pos.y = poi->rclItem.yTop; GpiLine( poi->hps, &pos ); // horizontal "dark" line pos.x = 1; pos.y = 1; GpiSetColor( poi->hps, SYSCLR_BUTTONDARK ); GpiMove( poi->hps, &pos ); pos.x = poi->rclItem.xRight; GpiLine( poi->hps, &pos ); poi->fsAttributeOld = (poi->fsAttribute &= ~MIA_HILITED); return MRFROMLONG( TRUE ); }
void PaintClient (HPS hps, SHORT cxClient, SHORT cyClient) { static CHAR szText [] = "ZED" ; POINTL ptl, ptlShear ; // Create the logical font CreateOutlineFont (hps, LCID_FONT, "Times New Roman", 0, 0) ; GpiSetCharSet (hps, LCID_FONT) ; // Display the shadow GpiSetColor (hps, CLR_DARKBLUE) ; ScaleOutlineFont (hps, 2160, 720) ; ptlShear.x = 1 ; //was 2 ptlShear.y = 1 ; GpiSetCharShear (hps, &ptlShear) ; ptl.x = cxClient / 8 ; ptl.y = cyClient / 4 ; GpiCharStringAt (hps, &ptl, strlen (szText), szText) ; // Display the text GpiSetColor (hps, CLR_WHITE) ; ScaleOutlineFont (hps, 720, 720) ; ptlShear.x = 0 ; ptlShear.y = 1 ; GpiSetCharShear (hps, &ptlShear) ; GpiCharStringAt (hps, &ptl, strlen (szText), szText) ; // Select the default font; delete the logical font GpiSetCharSet (hps, LCID_DEFAULT) ; GpiDeleteSetId (hps, LCID_FONT) ; }
void Paint(void) { HPS hps; RECTL rcl; hps = WinBeginPaint(hwndClient,(HPS)0,(PRECTL)&rcl); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLUE); GpiSetBackMix(hps,BM_OVERPAINT); WinFillRect(hps,&rcl,CLR_WHITE); WinEndPaint(hps); }
static void lineShadow(pLines pLin,HPS hps,WINDOWINFO *pwi, POINTL ptl1, POINTL ptl2) { POINTL p[2]; p[0] = ptl1; p[1] = ptl2; setShadingOffset(pwi,pLin->bt.Shade.lShadeType, pLin->bt.Shade.lUnits,p,2); GpiSetLineType(hps,pLin->bt.line.LineType); GpiSetColor(hps,pLin->bt.Shade.lShadeColor); drawLine(pLin,hps,pwi,p[0],p[1]); }
void ClearScreen(void) { HPS hps; RECTL rcl; WinInvalidateRect(hwndClient,(PRECTL)NULL,FALSE); hps = WinBeginPaint(hwndClient,(HPS)0,(PRECTL)&rcl); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLUE); GpiSetBackMix(hps,BM_OVERPAINT); WinFillRect(hps,&rcl,CLR_WHITE); WinEndPaint(hps); }
/************************************************************************** * * Name : DglKpyr(HPS* phps,int i, int j, long lColor) * * Description: рисует кружок в любом месте * * Concepts: Получает указатель на пространство отображения * и рисует круг размером BmpSize с координатами * i и j цвета lColor * * Parameters : phps - указатель на hps * i,j - координаты кружка * lColor - цвет кружка *************************************************************************/ VOID DglKpyr(PHPS phps,int i, int j, long lColor) { ARCPARAMS ap = {1,1,0,0};//ровный круг POINTL ptl;//куда и откуда рисовать GpiSetArcParams(*phps,&ap);//ровный круг GpiSetColor(*phps,CLR_WHITE);//белый ободок ptl.x = j+bs/2;//центр круга ptl.y = i+bs/2-1; GpiMove(*phps,&ptl);//в центр круга GpiFullArc(*phps,DRO_OUTLINE,//рисуем ободок MAKEFIXED(bs/2,bs/2)); GpiSetColor(*phps,lColor);//цвет внутренности GpiFullArc(*phps,DRO_FILL,//рисуем внутренность MAKEFIXED(bs/2-1,bs/2-1)); if(st){//рисуем элемент 3D RECTL rec;//где рисовать rec.xLeft = j+bs/2+1; rec.xRight = j+bs/2+bs/4+1; rec.yBottom = i+bs/2; rec.yTop = i+bs/2+bs/4; WinFillRect(*phps, &rec, CLR_WHITE);} } /* End of Kpyr */
SOM_Scope void SOMLINK ShapePartDrawFrame(ShapePart *somSelf, Environment *ev, ODFacet* facet, ODShape* invalidShape) { ShapePartData *somThis = ShapePartGetData(somSelf); ShapePartMethodDebug("ShapePart","ShapePartDrawFrame"); ODFrame* displayFrame = facet->GetFrame(ev); TempODShape shape = displayFrame->AcquireFrameShape(ev, facet->GetCanvas(ev)); ODRect rect; shape->GetBoundingBox(ev, &rect); #if defined(_PLATFORM_WIN32_) Rect frameRect; SetRect(&frameRect, FixedToInt(rect.left), FixedToInt(rect.top), FixedToInt(rect.right), FixedToInt(rect.bottom)); HDC hdc; CFocus focus(facet, invalidShape, &hdc); HBRUSH hbr = CreateSolidBrush (_fBackgroundColor); FillRect (hdc, &frameRect, hbr); DeleteObject (hbr); #elif defined (_PLATFORM_OS2_) RECTL frameRect; frameRect.xLeft = FixedToInt(rect.left); frameRect.yTop = FixedToInt(rect.top); frameRect.xRight = FixedToInt(rect.right); frameRect.yBottom = FixedToInt(rect.bottom); HPS hdc; CFocus focus(facet, invalidShape, &hdc); GpiCreateLogColorTable (hdc, 0L, LCOLF_RGB, 0L, 0L, 0L); GpiSetColor(hdc, _fBackgroundColor); POINTL orig = {0, 0}; GpiMove(hdc, &orig); POINTL ptl = {frameRect.xRight, frameRect.yTop}; GpiBox(hdc, DRO_FILL, &ptl, 0, 0); #endif }
MRESULT hchlb_wmPaint( HWND hwnd, MPARAM mp1, MPARAM mp2 ) { HPS hps; RECTL rcl; POINTL ptl; hps = WinBeginPaint( hwnd, NULLHANDLE, &rcl ); WinQueryWindowRect( hwnd, &rcl ); GpiSetColor( hps, SYSCLR_BUTTONDARK); ptl.x = rcl.xRight - 1; ptl.y = rcl.yTop - 1; GpiMove( hps, &ptl ); ptl.x = rcl.xLeft; GpiLine( hps, &ptl ); ptl.y = rcl.yBottom; GpiLine( hps, &ptl ); GpiSetColor( hps, SYSCLR_BUTTONLIGHT ); ptl.x = rcl.xLeft + 1; GpiMove( hps, &ptl ); ptl.x = rcl.xRight - 1; GpiLine( hps, &ptl ); ptl.y = rcl.yTop - 1; GpiLine( hps, &ptl ); WinEndPaint( hps ); return 0; }
void drawTransparent(HPS hps, PPOINTL p, XBITMAP *b) { BITMAPINFOHEADER bmpData; POINTL aptl[4]; if(!b->masc) return; bmpData.cbFix = sizeof(bmpData); GpiQueryBitmapParameters(b->masc, &bmpData); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); // Target - Inclusive aptl[0].x = p->x; aptl[0].y = p->y; aptl[1].x = p->x+bmpData.cx; aptl[1].y = p->y+bmpData.cy; // Source - Non inclusive aptl[2].x = 0; aptl[2].y = 0; aptl[3].x = bmpData.cx+1; aptl[3].y = bmpData.cy+1; GpiWCBitBlt( hps, b->masc, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); /* GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCCOPY, BBO_IGNORE); */ }
static void LboxDrawLine(HWND hwnd, OWNERITEM *item, RECTL *rcl, image_contents_screencode_t *line) { const HPS hps = item->hps; const int name = WinDlgLboxSelectedItem(hwnd, DID_FONTNAME_LB); FATTRS font = { sizeof(FATTRS), 0, 0, "", 0, 0, 8, 8, 0, 0 }; strcpy(font.szFacename, fnames[name]); GpiCreateLogFont(hps, NULL, 1, &font); GpiSetCharSet(hps, 1); GpiSetBackColor(hps, item->fsState ? CLR_DARKGRAY : CLR_WHITE); GpiSetColor(hps, item->fsState ? CLR_WHITE : CLR_DEFAULT); GpiCharStringPosAt(hps, (POINTL*)rcl, rcl, CHS_OPAQUE, line->length, line->line, NULL); GpiSetCharSet(hps, 0); GpiDeleteSetId(hps, 1); }
USHORT drawIcon(HPS hps, XBITMAP *b, USHORT id, USHORT x, USHORT y) { BITMAPINFOHEADER bmpData; POINTL aptl[4]; USHORT fator; if(!b->masc) return 0; bmpData.cbFix = sizeof(bmpData); GpiQueryBitmapParameters(b->masc, &bmpData); aptl[0].x = x; aptl[0].y = y; aptl[1].x = x+bmpData.cy-1; aptl[1].y = y+bmpData.cy-1; fator = bmpData.cy * id; aptl[2].x = fator; aptl[2].y = 0; aptl[3].x = fator + bmpData.cy; aptl[3].y = bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, b->masc, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); return bmpData.cy; }
// disegna il controllo groupbox MRESULT PaintGroupBox(HWND hwnd) { PCTL pgb = stGetData(hwnd); if (pgb) { RECTL rcl = {0, 0, pgb->wr.cx, pgb->wr.cy}; HPS hps = WinBeginPaint(hwnd, NULLHANDLE, NULL); ULONG brd = pgb->fl & 0x7; ULONG frm = brd; GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL); // disegna bordo groupbox WinDrawBorder(hps, &rcl, brd, brd, 0, 0, (pgb->fl & CCTL_RAISED? 0x400: 0x800)); // se necessario disegnare anche frame if (pgb->fl & CCTL_FRAME6) { frm = brd * ((pgb->fl & 0x38) >> 3); rcl.xLeft = frm; rcl.yBottom = frm; rcl.xRight -= frm; rcl.yTop -= frm; WinDrawBorder(hps, &rcl, brd, brd, 0, 0, (pgb->fl & CCTL_RAISED? 0x800: 0x400)); } /* endif */ // se il testo Š presente if (pgb->psz) { // cancella background rcl.xLeft = frm; rcl.yBottom = pgb->wr.cy - pgb->cyFont - 2 * frm - 2; rcl.xRight = pgb->wrtxt.cx + 2 * frm + 3; rcl.yTop = pgb->wr.cy - frm; WinFillRect(hps, &rcl, pgb->lbkgnd); // disegna testo rcl.yBottom += 2; WinDrawText(hps, -1, pgb->psz, &rcl, pgb->lfgnd, pgb->lbkgnd, DT_CENTER | DT_TOP | DT_MNEMONIC | DT_EXTERNALLEADING | ((pgb->fl & WS_DISABLED)? DT_HALFTONE: 0)); // disegna bordo inferiore e a destra del testo rcl.yBottom -= 2; GpiSetColor(hps, (pgb->fl & CCTL_RAISED? pgb->lshadow: pgb->lhilite)); GpiMove(hps, (PPOINTL)&rcl); rcl.xLeft = rcl.xRight; rcl.yTop -= 1; GpiPolyLine(hps, 2, (PPOINTL)&rcl); } /* endif */ WinEndPaint(hps); } /* endif */
//-------------------------------------------------------------------------- // // DrawShearedBox // // -------------------------------------------------------------------------- void DrawShearedBox( HWND hwnd ) { HPS hps; POINTL pointl; MATRIXLF m; // Get a cached PS for the window hps = WinGetPS( hwnd ); // Query the current contents of the model transform GpiQueryModelTransformMatrix( hps, 9L, &m ); m.fxM21 = MAKEFIXED(1,0); // tan(45) // m.fxM22 = MAKEFIXED(1,0); // identity // Replace the model transform with our modified one GpiSetModelTransformMatrix( hps, 9L, &m, TRANSFORM_REPLACE ); // Set the current position to (0,100) pointl.x = 400; pointl.y = 200; GpiSetCurrentPosition( hps, &pointl ); // Draw a 100 by 100 box from the current position in the // current color. pointl.x = pointl.y = 100; GpiSetColor( hps, CLR_BLUE ); GpiSetPattern( hps, PATSYM_HALFTONE ); GpiBox( hps, DRO_OUTLINEFILL, &pointl,0,0 ); // Free the cached PS WinReleasePS( hps ); }
/*----------------------------------------------------------------------*/ VOID DrawLine(WINDOWINFO *pwi,POINTL ptlSt,POINTL ptlE, short mode,POBJECT pObj) { pLines pLin; if (pObj && pObj->usClass == CLS_LIN) pLin = (pLines)pObj; else pLin = (pLines)0; if ( mode == CREATEMODE) GpiSetMix(pwi->hps,FM_INVERT); else { GpiSetMix(pwi->hps,FM_DEFAULT); GpiSetColor(pwi->hps,pwi->ulOutLineColor); GpiSetLineType(pwi->hps,pwi->lLntype); } if ( mode != CREATEMODE && pwi->lLnWidth > 1) { GpiSetPattern(pwi->hps,PATSYM_SOLID); GpiSetLineJoin(pwi->hps,pwi->lLnJoin); GpiSetLineEnd(pwi->hps,pwi->lLnEnd); GpiSetLineWidthGeom (pwi->hps,pwi->lLnWidth); GpiBeginPath( pwi->hps, 1L); } GpiMove(pwi->hps,&ptlSt); GpiLine(pwi->hps,&ptlE); if ( mode != CREATEMODE && pwi->lLnWidth > 1) { GpiEndPath(pwi->hps); GpiStrokePath (pwi->hps, 1, 0); } if (pLin) drwEndPoints(pwi,pLin->bt.arrow,ptlSt,ptlE); else drwEndPoints(pwi,pwi->arrow,ptlSt,ptlE); }
/************************************************************************** * * Name : CTPOKA(HPS* phps, BOOL bAll) * * Description: рисует буквы * * Concepts: Получает указатель на пространство отображения * и пишет текущие атрибуты игры: уровень и очки. * * API's : * * Parameters : phps - указатель на hps * usAll = перерисовывать все или только очки * 0 - очки * 1 - все * 2 - время *************************************************************************/ VOID CTPOKA(PHPS phps, USHORT usAll) { POINTL ptl;//где рисовать RECTL rec;//фон char sz[20]; if(usAll)rec.xLeft = 0;//пишем все,время,уровень else rec.xLeft = LevelEndptl.x;//очки if(usAll == 2)//пишем время rec.xRight = TimeEndptl.x;//TimeEndptl уже вызывалось else rec.xRight = Col*BmpSize+2;//пишем все,очки,уровень rec.yBottom = BmpSize*Row; rec.yTop = BmpSize*Row+LineHeight; WinFillRect(*phps, &rec, CLR_STRING); GpiSetColor(*phps,CLR_CHAR);//цвет внутренности ptl.y=BmpSize*Row+5; if(usAll == 2 || usAll == 1){//пишем все или время sprintf(sz,"Tijd-%d ",usTime); ptl.x = 5; GpiCharStringAt(*phps,&ptl,strlen(sz),sz); GpiQueryCurrentPosition(*phps,&TimeEndptl);} if(usAll == 1){//если пишем все sprintf(sz,"Niveau-%d ",usLevel); ptl.x = LevelBeginptl.x; GpiCharStringAt(*phps,&ptl,strlen(sz),sz); GpiQueryCurrentPosition(*phps,&LevelEndptl);} if(usAll == 0 || usAll == 1){//пишем все или очки sprintf(sz,"Punten-%d(%d%%) ", sScore, ((sScore - sOScore)*125)/((Row-2)*(Col-2)));// 4/5 поля=100% ptl.x = LevelEndptl.x; GpiCharStringAt(*phps,&ptl,strlen(sz),sz); GpiQueryCurrentPosition(*phps,&ScoreEndptl);} if(usAll == 1 && (ScoreEndptl.x > Col*BmpSize || LevelBeginptl.x < TimeEndptl.x )) { //sprintf(sz,"T-%d,L-%d,S-%d,CB-%d",TimeEndptl.x+5,LevelBeginptl.x,ScoreEndptl.x,Col*BmpSize); //WinMessageBox(HWND_DESKTOP,HWND_DESKTOP, // sz,"OneMore",0,MB_OK); LevelBeginptl.x = MAX(TimeEndptl.x+5, LevelBeginptl.x-(ScoreEndptl.x - Col*BmpSize+5)); CTPOKA(phps, usAll);} } /* End of CTPOKA */
VOID GRAPHBOARD::ShowPointerPos( HPS hps, LONG ptx, LONG pty ) { POINTL Point; Point.x = LowerLeftPlace.x + (GetBoardCol( ptx ) - 1) * dist; Point.y = LowerLeftPlace.y + (GetBoardRow( pty ) - 1) * dist; if( Point.x == DrawPoint.x && Point.y == DrawPoint.y ) return; // nothing to do if( GetfShowLines() ){ // if the help lines are visible, turn them off SetfShowLines( FALSE ); DisplayLines( hps ); } GpiSetMix( hps, FM_XOR ); GpiSetColor( hps, CLR_DARKGRAY ); if( DrawPoint.x >= LowerLeftPlace.x && DrawPoint.y >= LowerLeftPlace.y ) { // there exists a visible square that must be removed DrawPoint.x -= dist / 3; DrawPoint.y -= dist / 3; GpiMove( hps, &DrawPoint ); DrawPoint.x += 2 * dist / 3; DrawPoint.y += 2 * dist / 3; GpiBox( hps, DRO_OUTLINEFILL, &DrawPoint, 0, 0 ); } DrawPoint.x = Point.x; // DrawPoint is set to the new point DrawPoint.y = Point.y; if( Point.x >= LowerLeftPlace.x && Point.y >= LowerLeftPlace.y ){ // neither GetBoardCol nor GetBoardRow returned 0 => point is visible Point.x -= dist / 3; Point.y -= dist / 3; GpiMove( hps, &Point ); Point.x += 2 * dist / 3; Point.y += 2 * dist / 3; GpiBox( hps, DRO_OUTLINEFILL, &Point, 0, 0 ); } GpiSetMix( hps, FM_OVERPAINT ); }
void icqskin_drawSelected(HWND hwnd, HPS hps, PRECTL rcl, HBITMAP img, HBITMAP msk) { BITMAPINFOHEADER bmpData; USHORT cx = rcl->xRight - rcl->xLeft; int sz; int f; if(img == NO_IMAGE) { WinFillRect(hps, rcl, ICQCLR_SELECTEDBG); return; } GpiQueryBitmapParameters(img, &bmpData); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); if(cx > bmpData.cx) { sz = bmpData.cx / 3; for(f=rcl->xLeft+sz;f<(rcl->xRight-(sz*2));f+=sz) drawTransparent(hps, img, msk, f, rcl->yBottom, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, rcl->xRight-(sz*2), rcl->yBottom, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, rcl->xLeft, rcl->yBottom, sz, bmpData.cy, 0, 0); drawTransparent(hps, img, msk, rcl->xRight-sz, rcl->yBottom, sz, bmpData.cy, bmpData.cx-sz, 0); } else { sz = cx / 2; drawTransparent(hps, img, msk, rcl->xRight-sz, rcl->yBottom, sz, bmpData.cy, bmpData.cx-sz, 0); drawTransparent(hps, img, msk, rcl->xLeft, rcl->yBottom, sz, bmpData.cy, 0, 0); } }