Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
void XBox::Draw(XGraphicDevice * dev)
{
   if (!(settings & GO_HIDE))
   {
      XLine::SetupDevice(dev);

      POINTL ptl[5], po;

      po.x = p.x;
      po.y = p.y;
      ptl[0].x = ptl[4].x = p.x;
      ptl[0].y = ptl[4].y = p.y;
      ptl[1].x = p.x;
      ptl[1].y = ptl[2].y = height + p.y;
      ptl[3].x = ptl[2].x = width + p.x;
      ptl[3].y = p.y;

      GpiBeginPath(dev->hps, 1);
      GpiMove(dev->hps, &po);
      GpiPolyLine(dev->hps, 5, ptl);
      GpiEndPath(dev->hps);

      if (fill)
         GpiFillPath(dev->hps, 1, FPATH_ALTERNATE);
      else
         GpiOutlinePath(dev->hps, 1, 0);
//          GpiStrokePath( dev->hps, 1, 0);
   }
}
Exemplo n.º 3
0
void PMWindowImp::DeviceRect (
    Coord x0, Coord y0, Coord x1, Coord y1
) {
    Coord left = min(x0, x1);
    Coord right = max(x0, x1);
    Coord bottom = min(y0, y1);
    Coord top = max(y0, y1);
/*
*/
    PPOINTL point[4];
/*
*/
    point[0].x = left;    point[0].y = top;
    point[1].x = right;   point[1].y = top;
    point[2].x = right;   point[2].y = bottom;
    point[3].x = left;    point[3].y = bottom;
/*
*/
    if (
        (GpiBeginPath(_hps, 1L) == false) ||
        (GpiSetCurrentPosition(_hps, &point[3]) == false) ||
        (GpiPolyLine(_hps, 4L, point) == GPI_ERROR)  ||
        (GpiEndPath(_hps) == false)
    ) {
        // report error
/*
*/
    } else {
        GpiStrokePath(_hps, 1L, 0L);
    }
}
Exemplo n.º 4
0
VOID DrawHand (HPS hps, POINTL aptlIn[], INT iNum, INT iAngle,
               PWINDOWINFO pwi)
     {
     INT    iIndex ;
     POINTL aptl [5] ;

     for (iIndex = 0 ; iIndex < iNum ; iIndex++)
          aptl [iIndex] = aptlIn [iIndex] ;

     RotatePoint    (aptl, iNum, iAngle) ;
     ScalePoint     (aptl, iNum, pwi) ;
     TranslatePoint (aptl, iNum, pwi) ;

     GpiMove (hps, aptl) ;
     GpiPolyLine (hps, iNum - 1L, aptl + 1) ;
     }
Exemplo n.º 5
0
// 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 */
Exemplo n.º 6
0
//===========================================================================
// Draw the titlebar.
// Parameters --------------------------------------------------------------
// PSTLRFRAME p : windows data.
// Return value ------------------------------------------------------------
// VOID
//===========================================================================
static
VOID DrawTitlebar(PSTLRFRAME p) {
   PTBARAIOPT ptbo = p->is.tbhilited? &o.tb.a : &o.tb.i;
   POINTL apt[3];
   INT i;
   GpiCreateLogColorTable(p->hps, 0, LCOLF_RGB, 0, 0, NULL);
   // background ----------------------------------------------------------
   switch (ptbo->bkgnd) {
      // shade --------------------------------------------------------
      case TBARBKGNDSHADE:
         if (ptbo->shade) {         // sfumatura orizzontale
            WsetRect(apt, 0, 0, p->wrclTitle.cx, p->wrclTitle.cy);
            WinDrawBitmap(p->hps, ptbo->hbmp, NULL, apt, 0, 0, DBM_STRETCH);
         } else {                        // sfumatura verticale
            WsetRect(apt, 0, 0, p->wrclTitle.cx, SHADEH_CY);
            for (i = 0; i < p->wrclTitle.cy; i += 2) {
               WinDrawBitmap(p->hps, ptbo->hbmp, NULL, apt, 0, 0, DBM_STRETCH);
               ((PRECTL)apt)->yBottom += SHADEH_CY;
               ((PRECTL)apt)->yTop += SHADEH_CY;
            } /* endfor */
         } /* endif */
         break;
      // bitmap -------------------------------------------------------
      case TBARBKGNDBMP:
         WsetRect(&apt[1], 0, 0, p->wrclTitle.cx, p->wrclTitle.cy);
         if (ptbo->strch) {
            WinDrawBitmap(p->hps, ptbo->hbmp, NULL, &apt[1], 0, 0, DBM_STRETCH);
         } else {
            apt[0].x = apt[0].y = 0;
            while (apt[0].x <= p->wrclTitle.cx) {
               WinDrawBitmap(p->hps, ptbo->hbmp, (PRECTL)&apt[1], apt, 0, 0, 0);
               apt[0].x += ptbo->size.cx;
               apt[2].x = p->wrclTitle.cx - apt[0].x;
            } /* endwhile */
         } /* endif */
         break;
      // solid color --------------------------------------------------
      default:
         apt[0].x = p->wrclTitle.cx - 1;
         apt[0].y = p->wrclTitle.cy - 1;
         GpiSetColor(p->hps, ptbo->clrLeftTop.l);
         GpiBox(p->hps, DRO_OUTLINEFILL, apt, 0L, 0L);
         break;
   } /* endswitch */
   // text ----------------------------------------------------------------
   if (!p->cyfont) {
      GpiQueryTextBox(p->hps, p->cchTxt, p->achTxt, 3, apt);
      p->yfont = - apt[1].y;
      p->cyfont = apt[0].y - apt[1].y;
      p->cxfont = apt[2].x - apt[0].x;
   } /* endif */
   // se il testo Š pi— largo della finestra viene comunque allineato a sin.
   i = (p->cxfont < p->wrclTitle.cx) ? 8: 0;
   apt[0].x = (ptbo->center && i)? (p->wrclTitle.cx - p->cxfont) / 2 + 1: i + 3;
   apt[0].y = (p->wrclTitle.cy - p->cyfont) / 2 + p->yfont;
   apt[1].x = 0;
   apt[1].y = 0;
   apt[2].x = p->wrclTitle.cx - 1;
   apt[2].y = p->wrclTitle.cy - 1;
   if (ptbo->_3DTxt) {                         // disegna ombra testo
      GpiSetColor(p->hps, ptbo->clrBgTxt.l);
      GpiCharStringPosAt(p->hps, apt, (PRECTL)(apt + 1), CHS_CLIP,
                         p->cchTxt, p->achTxt, NULL);
   } /* endif */
   apt[0].x--;
   apt[0].y++;
   GpiSetColor(p->hps, ptbo->clrFgTxt.l);
   GpiCharStringPosAt(p->hps, apt, (PRECTL)(apt + 1), CHS_CLIP,
                      p->cchTxt, p->achTxt, NULL);
   // border --------------------------------------------------------------
   if (ptbo->border) {
      GpiMove(p->hps, &apt[1]);
      apt[1].y = apt[2].y;
      GpiSetColor(p->hps, ptbo->clrHiBkgnd.l);
      GpiPolyLine(p->hps, 2, &apt[1]);
      apt[1].x = apt[2].x;
      apt[1].y = 0;
      apt[2].x = 1;
      apt[2].y = 0;
      GpiSetColor(p->hps, ptbo->clrShBkgnd.l);
      GpiPolyLine(p->hps, 2, &apt[1]);
   } /* endif */
}
Exemplo n.º 7
0
MRESULT	EXPENTRY ROPsTestWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)

{
CHAR			szTitle[300];  /* Title	Bar Text		*/
HPS			hPS;	   /* Presentation Space Handle		*/
LONG			lClrBack;  /* Colour Holder			*/
LONG			lClrFore;  /* Colour Holder			*/
LONG			lScrollInc;/* Scroll Increment			*/
PBITMAPARRAYFILEHEADER	pbafh;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPARRAYFILEHEADER2	pbafh2;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPFILEHEADER	pbfh;	   /* Bitmap File Header Pointer	*/
PBITMAPFILEHEADER2	pbfh2;	   /* Bitmap File Header Pointer	*/
PBITMAPINFO		pbmi;	   /* Bitmap Info Pointer		*/
PBITMAPINFO2		pbmi2;	   /* Bitmap Info Pointer		*/
POINTL			ptl;	   /* Pointer Position			*/
RECTL			rcl;	   /* Window Rectangle			*/
register INT i;			   /* Index				*/

switch ( msg )
   {
/************************************************************************/
/* Window being	created, perform window	initialization			*/
/************************************************************************/

   case	WM_CREATE :

       hptrWait	 = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT,	FALSE);
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);

       cxScreen	= WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);

       hmenuROPs = WinWindowFromID(WinQueryWindow(hWnd,	QW_PARENT), FID_MENU);
       hwndHScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_HORZSCROLL);
       hwndVScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_VERTSCROLL);

		       /************************************************/
		       /* PDSGetTemplate is used to allow controls in  */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       PDSGetTemplate(hWnd, WIN_ROPSTEST);
       break;

/************************************************************************/
/* Window being	sized							*/
/************************************************************************/

   case	WM_SIZE	:
       if ( cBitmaps )
	   SizeBitmapStack(hWnd);

       WinQueryWindowRect(hWnd,	&rcl);

       if ( (lHorzRange	= cxROP	- (cxWindow = rcl.xRight - rcl.xLeft)) < 0L )
	   {
	   lHorzRange =	0L;
	   rclROP.xLeft	 = 0L;
	   rclROP.xRight = cxROP;
	   }
       else
	   rclROP.xRight = rclROP.xLeft	+ cxWindow;
       if ( (lVertRange	= cyROP	- (cyWindow = rcl.yTop - rcl.yBottom)) < 0L )
	   {
	   lVertRange =	0L;
	   rclROP.yBottom  = 0L;
	   rclROP.yTop	   = cyROP;
	   }
       else
	   rclROP.yBottom = (rclROP.yTop = cyROP - lVertPos) - cyWindow;

       WinSendMsg(hwndVScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lVertPos),
		  MPFROM2SHORT(0, lVertRange));
       WinSendMsg(hwndVScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cyWindow,	cyROP),	0L);

       WinSendMsg(hwndHScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lHorzPos),
		  MPFROM2SHORT(0, lHorzRange));
       WinSendMsg(hwndHScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cxWindow,	cxROP),	0L);
       WinInvalidateRect(hWnd, NULL, FALSE);
       break;

/************************************************************************/
/* Perform menu	initialization						*/
/************************************************************************/

   case	WM_INITMENU :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_DISPLAY :
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_BITMAPARRAY, TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? MIA_CHECKED : 0));
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_ROPARRAY,	TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? 0 : MIA_CHECKED));
	       break;

	   case	IDM_FILE :
	       break;

	   }
       break;

/************************************************************************/
/* Process key press from keyboard					*/
/************************************************************************/

   case	WM_CHAR	:
       if ( CHARMSG(&msg)->fs &	KC_VIRTUALKEY )
	   switch ( CHARMSG(&msg)->vkey	)
	       {
	       case VK_PAGEUP :
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEUP));
		   return(0L);

	       case VK_PAGEDOWN	:
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEDOWN));
		   return(0L);
	       }
		       /************************************************/
		       /* PDSKeyProc is	used to	allow controls in      */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       return(PDSKeyProc(hWnd, msg, mp1, mp2));

/************************************************************************/
/* Button 2 being depressed						*/
/************************************************************************/

   case	WM_BUTTON2DOWN :
       if ( !fBitmapArray && hbmROP )
	   {
	   lHorzPos = SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
	   lVertPos = SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));

	   lRop	= (lVertPos + (cyWindow	- SHORT2FROMMP(mp1))) /	cyImage	* 16 + (lHorzPos + SHORT1FROMMP(mp1)) /	cxImage;
	   WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)ViewROPDlgProc,
		     (HMODULE)NULL, DLG_VIEWROP, NULL);
	   }
       break;

/************************************************************************/
/* Process vertical scroll requests					*/
/************************************************************************/

   case	WM_VSCROLL :
       lVertPos	= SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINEUP :
	       lScrollInc = -cyImage;
	       break;

	   case	SB_LINEDOWN :
	       lScrollInc = cyImage;
	       break;

	   case	SB_PAGEUP :
	       lScrollInc = -cyWindow;
	       break;

	   case	SB_PAGEDOWN :
	       lScrollInc = cyWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lVertPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lVertPos,	min(lScrollInc,	lVertRange - lVertPos))	)
	   {
	   rclROP.yBottom = (rclROP.yTop = cyROP - (lVertPos +=	lScrollInc)) - cyWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndVScroll, SBM_SETPOS, MPFROM2SHORT(lVertPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process horizontal scroll requests					*/
/************************************************************************/

   case	WM_HSCROLL :
       lHorzPos	= SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINELEFT :
	       lScrollInc = -cxImage;
	       break;

	   case	SB_LINERIGHT :
	       lScrollInc = cxImage;
	       break;

	   case	SB_PAGELEFT :
	       lScrollInc = -cxWindow;
	       break;

	   case	SB_PAGERIGHT :
	       lScrollInc = cxWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lHorzPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lHorzPos,	min(lScrollInc,	lHorzRange - lHorzPos))	)
	   {
	   rclROP.xRight = (rclROP.xLeft = (lHorzPos +=	lScrollInc)) + cxWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndHScroll, SBM_SETPOS, MPFROM2SHORT(lHorzPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process control selections						*/
/************************************************************************/

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
	   }
       break;

/************************************************************************/
/* Process menu	and button selections					*/
/************************************************************************/

   case	WM_COMMAND :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_OPTIONS :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OptionsDlgProc,
			      (HMODULE)NULL, DLG_OPTIONS, NULL)	)
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;
	   case	IDM_OPEN :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OpenBitmapDlgProc,
			      (HMODULE)NULL, DLG_OPENBITMAP, NULL) )
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   hbmView = hbmGetBitmap(szBitmapFile);
		   SizeBitmap(hWnd);
		   if (	cBitmaps )
		       SizeBitmapStack(hWnd);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   strcat(memcpy(szTitle, "Bitmap Viewer - ", 17), szBitmapFile);
		   if (	fWindowsBitmap )
		       strcat(szTitle, " [Windows 3.x format]");
		   else
		       if ( f20Bitmap )
			   strcat(szTitle, " [OS/2 2.x format]");
		       else
			   strcat(szTitle, " [OS/2 1.x format]");
		   WinSetWindowText(hwndROPsFrame, szTitle);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;

	   case	IDM_ROPARRAY :
	       fBitmapArray = FALSE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;

	   case	IDM_BITMAPARRAY	:
	       fBitmapArray = TRUE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;
	   }
       break;

/************************************************************************/
/* Erase window	background						*/
/************************************************************************/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)LONGFROMMP(mp1), &rcl, CLR_PALEGRAY);
       break;

/************************************************************************/
/* Paint client	window							*/
/************************************************************************/

   case	WM_PAINT :
       GpiCreateLogColorTable(hPS = WinBeginPaint(hWnd,	(HPS)NULL, &rcl), 0UL, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

		       /* Display the bitmap array images side-by-side	*/
       if ( fBitmapArray )
	   {
	   WinFillRect(hPS, &rcl, RGBCLR_PALEGRAY);
	   for ( i = 0;	i < cBitmaps; i++ )
	       {
		       /* Check	to see if the image is a 2-colour which	*/
		       /* menas	that the colours have to be set		*/
		       /* explicitely					*/

	       if ( abm[i].cColours == 2L )
		   {
		   lClrBack = lClrFore = 0L;

		       /* Check	to see if a 2.x	format bitmap since the	*/
		       /* the structures are slightly different		*/

		   if (	f20Bitmap )
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh2 = (PBITMAPFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbfh2->bmp2;
			   }
		       else
			   {
			   pbafh2 = (PBITMAPARRAYFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbafh2->bfh2.bmp2;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi2->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi2->argbColor[1], 3);
		       }
		   else
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh	= (PBITMAPFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbfh->bmp;
			   }
		       else
			   {
			   pbafh = (PBITMAPARRAYFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbafh->bfh.bmp;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi->argbColor[1], 3);
		       }
			   /* Draw the 2-colour	bitmap using the	*/
			   /* provided colours from the	bitmap		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 lClrFore, lClrBack, DBM_NORMAL);
		   }
	       else
			   /* Draw the bitmap from the array		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 RGB_WHITE, RGB_BLACK, DBM_NORMAL);

			   /* Draw the 3-D frame around	the image	*/

	       GpiSetColor(hPS,	RGBCLR_SHADOW);
	       GpiMove(hPS, &abm[i].aptlArea[7]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[4]);

	       GpiSetColor(hPS,	RGB_WHITE);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[6]);

	       GpiSetColor(hPS,	RGB_BLACK);
	       GpiMove(hPS, &abm[i].aptlArea[3]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[0]);

	       GpiSetColor(hPS,	RGBCLR_PALEGRAY);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[2]);
	       }
	   }
       else
	   {
	   if (	(rclROP.xRight < cxWindow) || (rclROP.yTop < cyWindow) )
	       WinFillRect(hPS,	&rcl, RGBCLR_PALEGRAY);
	   ptl.x = ptl.y = 0L;
	   WinDrawBitmap(hPS, hbmROP, &rclROP, &ptl, 0L, 0L, DBM_NORMAL);
	   }
       WinEndPaint(hPS);
       break;

/************************************************************************/
/* Window being	destroyed, perform clean-up operations			*/
/************************************************************************/

   case	WM_DESTROY :
       for ( i = 0; i <	cBitmaps; i++ )
	   GpiDeleteBitmap(abm[i].hbm);

       if ( hbmROP )
	   GpiDeleteBitmap(hbmROP);

       if ( pb )
	   free(pb);
       break;

			/* Default message processing			*/
   default :
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
Exemplo n.º 8
0
MRESULT EXPENTRY XLogoWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  HPS hps;
  HWND hwndMenu;                                        /* Menu resource */
  RECTL rcl;                    /* For finding current window dimensions */
  BOOL fSuccess;

  switch(msg)
  {
   case WM_ERASEBACKGROUND:
      /*
       * Return TRUE to request PM to paint the window background
       * in SYSCLR_WINDOW.
       */
      return (MRESULT)( TRUE );

    case WM_PAINT:
      /*
       * Window contents are drawn here in WM_PAINT processing.
       */
      {                                
      HPS    hps;                        /* Presentation Space handle    */
      RECTL  rc;                         /* Rectangle coordinates        */
      POINTL pt;                         /* String screen coordinates    */
      LONG   Lx, Ly;
                                    /* Starting points for paths A and B */
      POINTL PathAStart,
             PathBStart;

      POINTL PathAPolygon[5], PathBPolygon[5]; /* Paths A, B definitions */

                                         /* Create a presentation space  */
      hps = WinBeginPaint( hwnd, 0L, &rc );

      GpiSetColor(hps, CLR_BLACK);              /* colour of the text,   */
      GpiSetBackColor(hps, CLR_BACKGROUND);     /* its background and    */
      GpiSetBackMix(hps, BM_OVERPAINT);         /* how it mixes,         */
                                                /* and draw the string...*/

      WinFillRect( hps, &rc, SYSCLR_WINDOW);
      WinQueryWindowRect(hwnd, &rcl);

      Lx = rcl.xRight - rcl.xLeft;       /* Calculate window dimensions! */
      Ly = rcl.yTop   - rcl.yBottom;

            /* Find starting points of the two paths which make up the X */

      PathAStart.x = 0.061 * Lx;
      PathAStart.y = Ly;
      PathBStart.x = 0.864 * Lx;
      PathBStart.y = Ly;

                  /* Find the points for path A, the left half of the X */

      PathAPolygon[0].x = 0.404 * Lx;
      PathAPolygon[0].y = 0.483 * Ly;

      PathAPolygon[1].x = 0.06  * Lx;
      PathAPolygon[1].y = 0;

      PathAPolygon[2].x = 0.141 * Lx;
      PathAPolygon[2].y = 0;

      PathAPolygon[3].x = 0.556 * Lx;
      PathAPolygon[3].y = 0.589 * Ly;

      PathAPolygon[4].x = 0.288 * Lx;
      PathAPolygon[4].y = Ly;

                  /* Find the points for path B, the right half of the X */

      PathBPolygon[0].x = 0.455 * Lx;
      PathBPolygon[0].y = 0.417 * Ly;

      PathBPolygon[1].x = 0.722 * Lx;
      PathBPolygon[1].y = 0;

      PathBPolygon[2].x = 0.939 * Lx;
      PathBPolygon[2].y = 0;

      PathBPolygon[3].x = 0.6   * Lx;
      PathBPolygon[3].y = 0.517 * Ly;

      PathBPolygon[4].x = 0.939 * Lx;
      PathBPolygon[4].y = Ly;
                                               /* Define and draw path A */
      GpiBeginPath(hps, 1L);
      GpiMove(hps, &PathAStart);
      GpiPolyLine(hps, 5L, PathAPolygon);
      GpiCloseFigure(hps);
      GpiEndPath(hps);
      GpiFillPath(hps, 1L, FPATH_ALTERNATE);

                      /* Define and draw path B. Path number must be 1L */
      GpiBeginPath(hps, 1L);
      GpiMove(hps, &PathBStart);
      GpiPolyLine(hps, 5L, PathBPolygon);
      GpiCloseFigure(hps);
      GpiEndPath(hps);
      GpiFillPath(hps, 1L, FPATH_ALTERNATE);

      WinEndPaint(hps);
      break;
      }

   case WM_BUTTON2DOWN:
      {           /* Opens the popup menu at current mouse co-ordinates */

      hwndMenu = WinLoadMenu(hwnd, (HMODULE)NULL, ID_X);

      fSuccess = WinPopupMenu(hwnd,
                              hwndFrame,
                              hwndMenu,
                              MOUSEMSG(&msg)->x,              
                              MOUSEMSG(&msg)->y,
                              IDM_EXIT,
                              PU_POSITIONONITEM   |
                              PU_HCONSTRAIN       |
                              PU_VCONSTRAIN       |
                              PU_MOUSEBUTTON2DOWN |
                              PU_MOUSEBUTTON2);

      break;
      }

    case WM_CLOSE:
      /*
       * This is the place to put your termination routines
       */
      WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );
      break;

    case WM_COMMAND:
       switch (SHORT1FROMMP (mp1))
        {
        case IDM_ABOUT:          /* Show Product information dialog box */

          WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc,
                    0, IDD_ABOUT, 0);

          return ((MRESULT)0);
        case IDM_EXIT:
          WinSendMsg (hwnd, WM_CLOSE, 0L, 0L);
          return ((MRESULT)0);
        }
      break;

    default:
      /*
       * Everything else comes here.  This call MUST exist
       * in your window procedure.
       */

      return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  }

  return (MRESULT)FALSE;
} /* End of XLogoWndProc */