Exemplo n.º 1
0
HRESULT CGifSmileyCtrl::OnDrawSmiley(ATL_DRAWINFO& di, bool bCustom=false)
{
	USES_CONVERSION;
	if (di.dwDrawAspect != DVASPECT_CONTENT)
	{
		return E_FAIL;
	}
	if ( bCustom && !IsVisible(di))
	{
		return S_OK;
	}
	if (!m_pGifImage)
	{
		return E_FAIL;
	}
	RECT& rc = *(RECT*)di.prcBounds;

	HRGN hOldRgn, hNewRgn;

	if (!IsRectEmpty(&m_rectPos))
	{   //strange workaround for drawing zoom out smileys (look MS calculate it one pix larger than exactly)
		if (rc.bottom-rc.top-1 == m_rectPos.bottom-m_rectPos.top 
			&& rc.right-rc.left== m_rectPos.right-m_rectPos.left)
			rc.top+=1;
	}

	if ( bCustom )SelectSmileyClipRgn(di.hdcDraw, rc, hOldRgn, hNewRgn, TRUE);

	InflateRect(&rc,-1,0); //border offset to fix blinked cursor painting
	if ( (m_dwFlags&REO_INVERTEDSELECT) == 0 || !bCustom || m_bTransparent)
		DoDrawSmiley(di.hdcDraw, rc, rc.right-rc.left,rc.bottom-rc.top, m_nFrameSize.Width, m_nFrameSize.Height);
	else
	{
		Bitmap bmp(rc.right-rc.left,rc.bottom-rc.top, PixelFormat32bppARGB);
		Graphics g(&bmp);
		COLORREF col=(COLORREF)(m_clrBackColor);
		SolidBrush brush(Color(GetRValue(col),GetGValue(col),GetBValue(col)));
		g.FillRectangle( &brush, 0 ,0, rc.right-rc.left, rc.bottom-rc.top);
		HDC hdc=g.GetHDC();
		RECT mrc={0};
		mrc.right=rc.right-rc.left;
		mrc.bottom=rc.bottom-rc.top;
		DoDrawSmiley(hdc, mrc, mrc.right-mrc.left,mrc.bottom-mrc.top, m_nFrameSize.Width, m_nFrameSize.Height);
		InvertRect(hdc, &mrc);
		BitBlt(di.hdcDraw, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc, 0, 0, SRCCOPY );
		g.ReleaseHDC(hdc);       
	}
	if ((m_dwFlags&REO_SELECTED) == REO_SELECTED && bCustom)
	{
		//Draw frame around
		HBRUSH oldBrush=(HBRUSH)SelectObject(di.hdcDraw, GetStockObject(NULL_BRUSH)); 
		HPEN oldPen=(HPEN)SelectObject(di.hdcDraw, GetStockObject(BLACK_PEN));
		::Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom );
		SelectObject(di.hdcDraw, oldBrush);
		SelectObject(di.hdcDraw, oldPen);
	}
	AdvanceFrame();
	if (!bCustom) 
		m_bPaintValid=false;
	ResetClip(di.hdcDraw, hOldRgn, hNewRgn);

	return S_OK;
}
Exemplo n.º 2
0
void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
{
	HDC hdcMem;
	RECT clRect;
	int y, indent, index, fontHeight;
	struct ClcGroup *group;
	HFONT hOldFont;
	DWORD style = GetWindowLong(hwnd, GWL_STYLE);
	int status = GetGeneralisedStatus();
	int grey = 0, groupCountsFontTopShift;
	HBRUSH hBrushAlternateGrey = NULL;
	// yes I know about GetSysColorBrush()
	COLORREF tmpbkcolour = style & CLS_CONTACTLIST ? (dat->useWindowsColours ? GetSysColor(COLOR_3DFACE) : dat->bkColour) : dat->bkColour;

	if (dat->greyoutFlags & pcli->pfnClcStatusToPf2(status) || style & WS_DISABLED)
		grey = 1;
	else if (GetFocus() != hwnd && dat->greyoutFlags & GREYF_UNFOCUS)
		grey = 1;
	GetClientRect(hwnd, &clRect);
	if (rcPaint == NULL)
		rcPaint = &clRect;
	if (IsRectEmpty(rcPaint))
		return;
	y = -dat->yScroll;
	hdcMem = CreateCompatibleDC(hdc);
	HBITMAP hBmpOsb = CreateBitmap(clRect.right, clRect.bottom, 1, GetDeviceCaps(hdc, BITSPIXEL), NULL);
	HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcMem, hBmpOsb);
	{
		TEXTMETRIC tm;
		hOldFont = (HFONT)SelectObject(hdcMem, dat->fontInfo[FONTID_GROUPS].hFont);
		GetTextMetrics(hdcMem, &tm);
		groupCountsFontTopShift = tm.tmAscent;
		SelectObject(hdcMem, dat->fontInfo[FONTID_GROUPCOUNTS].hFont);
		GetTextMetrics(hdcMem, &tm);
		groupCountsFontTopShift -= tm.tmAscent;
	}
	if (style & CLS_GREYALTERNATE)
		hBrushAlternateGrey =
		CreateSolidBrush(GetNearestColor(hdcMem, RGB(GetRValue(tmpbkcolour) - 10, GetGValue(tmpbkcolour) - 10, GetBValue(tmpbkcolour) - 10)));

	ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight);
	SetBkMode(hdcMem, TRANSPARENT);
	{
		HBRUSH hBrush;

		hBrush = CreateSolidBrush(tmpbkcolour);
		FillRect(hdcMem, rcPaint, hBrush);
		DeleteObject(hBrush);
		if (dat->hBmpBackground) {
			BITMAP bmp;
			HDC hdcBmp;
			int x, y;
			int maxx, maxy;
			int destw, desth;

			// XXX: Halftone isnt supported on 9x, however the scretch problems dont happen on 98.
			SetStretchBltMode(hdcMem, HALFTONE);

			GetObject(dat->hBmpBackground, sizeof(bmp), &bmp);
			hdcBmp = CreateCompatibleDC(hdcMem);
			SelectObject(hdcBmp, dat->hBmpBackground);
			y = dat->backgroundBmpUse & CLBF_SCROLL ? -dat->yScroll : 0;
			maxx = dat->backgroundBmpUse & CLBF_TILEH ? clRect.right : 1;
			maxy = dat->backgroundBmpUse & CLBF_TILEV ? maxy = rcPaint->bottom : y + 1;
			switch (dat->backgroundBmpUse & CLBM_TYPE) {
			case CLB_STRETCH:
				if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) {
					if (clRect.right * bmp.bmHeight < clRect.bottom * bmp.bmWidth) {
						desth = clRect.bottom;
						destw = desth * bmp.bmWidth / bmp.bmHeight;
					}
					else {
						destw = clRect.right;
						desth = destw * bmp.bmHeight / bmp.bmWidth;
					}
				}
				else {
					destw = clRect.right;
					desth = clRect.bottom;
				}
				break;
			case CLB_STRETCHH:
				if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) {
					destw = clRect.right;
					desth = destw * bmp.bmHeight / bmp.bmWidth;
				}
				else {
					destw = clRect.right;
					desth = bmp.bmHeight;
				}
				break;
			case CLB_STRETCHV:
				if (dat->backgroundBmpUse & CLBF_PROPORTIONAL) {
					desth = clRect.bottom;
					destw = desth * bmp.bmWidth / bmp.bmHeight;
				}
				else {
					destw = bmp.bmWidth;
					desth = clRect.bottom;
				}
				break;
			default:       //clb_topleft
				destw = bmp.bmWidth;
				desth = bmp.bmHeight;
				break;
			}
			for (; y < maxy; y += desth) {
				if (y < rcPaint->top - desth)
					continue;
				for (x = 0; x < maxx; x += destw)
					StretchBlt(hdcMem, x, y, destw, desth, hdcBmp, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
			}
			DeleteDC(hdcBmp);
		}
	}
	group = &dat->list;
	group->scanIndex = 0;
	indent = 0;
	for (index = 0; y < rcPaint->bottom;) {
		if (group->scanIndex == group->cl.count) {
			group = group->parent;
			indent--;
			if (group == NULL)
				break;
			group->scanIndex++;
			continue;
		}
		if (y > rcPaint->top - dat->rowHeight) {
			int iImage = -1;
			int selected = index == dat->selection && (dat->showSelAlways || dat->exStyle & CLS_EX_SHOWSELALWAYS || GetFocus() == hwnd)
				&& group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER;
			int hottrack = dat->exStyle & CLS_EX_TRACKSELECT && group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER && dat->iHotTrack == index;
			SIZE textSize, countsSize, spaceSize;
			int width, checkboxWidth;
			char *szCounts;

			//alternating grey
			if (style & CLS_GREYALTERNATE && index & 1) {
				RECT rc;
				rc.top = y;
				rc.bottom = rc.top + dat->rowHeight;
				rc.left = 0;
				rc.right = clRect.right;
				FillRect(hdcMem, &rc, hBrushAlternateGrey);
			}

			//setup
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP)
				ChangeToFont(hdcMem, dat, FONTID_GROUPS, &fontHeight);
			else if (group->cl.items[group->scanIndex]->type == CLCIT_INFO) {
				if (group->cl.items[group->scanIndex]->flags & CLCIIF_GROUPFONT)
					ChangeToFont(hdcMem, dat, FONTID_GROUPS, &fontHeight);
				else
					ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight);
			}
			else if (group->cl.items[group->scanIndex]->type == CLCIT_DIVIDER)
				ChangeToFont(hdcMem, dat, FONTID_DIVIDERS, &fontHeight);
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_NOTONLIST)
				ChangeToFont(hdcMem, dat, FONTID_NOTONLIST, &fontHeight);
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT &&
				((group->cl.items[group->scanIndex]->flags & CONTACTF_INVISTO
				&& GetRealStatus(group->cl.items[group->scanIndex], status) != ID_STATUS_INVISIBLE)
				|| (group->cl.items[group->scanIndex]->flags & CONTACTF_VISTO
				&& GetRealStatus(group->cl.items[group->scanIndex], status) == ID_STATUS_INVISIBLE)
				)
				) {
					// the contact is in the always visible list and the proto is invisible
					// the contact is in the always invisible and the proto is in any other mode
					ChangeToFont(hdcMem, dat, group->cl.items[group->scanIndex]->flags & CONTACTF_ONLINE ? FONTID_INVIS : FONTID_OFFINVIS, &fontHeight);
				}
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && !(group->cl.items[group->scanIndex]->flags & CONTACTF_ONLINE))
				ChangeToFont(hdcMem, dat, FONTID_OFFLINE, &fontHeight);
			else
				ChangeToFont(hdcMem, dat, FONTID_CONTACTS, &fontHeight);
			GetTextExtentPoint32(hdcMem, group->cl.items[group->scanIndex]->szText, lstrlen(group->cl.items[group->scanIndex]->szText), &textSize);
			width = textSize.cx;
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP) {
				szCounts = pcli->pfnGetGroupCountsText(dat, group->cl.items[group->scanIndex]);
				if (szCounts[0]) {
					GetTextExtentPoint32A(hdcMem, " ", 1, &spaceSize);
					ChangeToFont(hdcMem, dat, FONTID_GROUPCOUNTS, &fontHeight);
					GetTextExtentPoint32A(hdcMem, szCounts, lstrlenA(szCounts), &countsSize);
					width += spaceSize.cx + countsSize.cx;
				}
			}

			if ((style & CLS_CHECKBOXES && group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) ||
				(style & CLS_GROUPCHECKBOXES && group->cl.items[group->scanIndex]->type == CLCIT_GROUP) ||
				(group->cl.items[group->scanIndex]->type == CLCIT_INFO && group->cl.items[group->scanIndex]->flags & CLCIIF_CHECKBOX))
				checkboxWidth = dat->checkboxSize + 2;
			else
				checkboxWidth = 0;

			//background
			if (selected) {
				int x = dat->leftMargin + indent * dat->groupIndent + checkboxWidth + dat->iconXSpace - 2;
				ImageList_DrawEx(dat->himlHighlight, 0, hdcMem, x, y, min(width + 5, clRect.right - x), dat->rowHeight, CLR_NONE, CLR_NONE,
					dat->exStyle & CLS_EX_NOTRANSLUCENTSEL ? ILD_NORMAL : ILD_BLEND25);
				SetTextColor(hdcMem, dat->selTextColour);
			}
			else if (hottrack)
				SetHotTrackColour(hdcMem, dat);

			//checkboxes
			if (checkboxWidth) {
				RECT rc;
				HANDLE hTheme = OpenThemeData(hwnd, L"BUTTON");
				rc.left = dat->leftMargin + indent * dat->groupIndent;
				rc.right = rc.left + dat->checkboxSize;
				rc.top = y + ((dat->rowHeight - dat->checkboxSize) >> 1);
				rc.bottom = rc.top + dat->checkboxSize;
				DrawThemeBackground(hTheme, hdcMem, BP_CHECKBOX, group->cl.items[group->scanIndex]->flags & CONTACTF_CHECKED ? (hottrack ? CBS_CHECKEDHOT : CBS_CHECKEDNORMAL) : (hottrack ? CBS_UNCHECKEDHOT : CBS_UNCHECKEDNORMAL), &rc, &rc);
				CloseThemeData(hTheme);
			}

			//icon
			if (group->cl.items[group->scanIndex]->type == CLCIT_GROUP)
				iImage = group->cl.items[group->scanIndex]->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
			else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT)
				iImage = group->cl.items[group->scanIndex]->iImage;
			if (iImage != -1) {
				/*COLORREF colourFg=dat->selBkColour;
				int mode=ILD_NORMAL;
				if(selected) mode=ILD_SELECTED;
				else if(hottrack) {mode=ILD_FOCUS; colourFg=dat->hotTextColour;}
				else if(group->cl.items[group->scanIndex]->type==CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags&CONTACTF_NOTONLIST) {colourFg=dat->fontInfo[FONTID_NOTONLIST].colour; mode=ILD_BLEND50;}
				ImageList_DrawEx(himlCListClc,iImage,hdcMem,dat->leftMargin+indent*dat->groupIndent+checkboxWidth,y+((dat->rowHeight-16)>>1),0,0,CLR_NONE,colourFg,mode);
				*/
				// this doesnt use CLS_CONTACTLIST since the colour prolly wont match anyway
				COLORREF colourFg = dat->selBkColour;
				int mode = ILD_NORMAL;
				if (hottrack) {
					colourFg = dat->hotTextColour;
				}
				else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && group->cl.items[group->scanIndex]->flags & CONTACTF_NOTONLIST) {
					colourFg = dat->fontInfo[FONTID_NOTONLIST].colour;
					mode = ILD_BLEND50;
				}
				if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT && dat->showIdle
					&& (group->cl.items[group->scanIndex]->flags & CONTACTF_IDLE)
					&& GetRealStatus(group->cl.items[group->scanIndex], ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
					mode = ILD_SELECTED;
				ImageList_DrawEx(himlCListClc, iImage, hdcMem, dat->leftMargin + indent * dat->groupIndent + checkboxWidth,
					y + ((dat->rowHeight - 16) >> 1), 0, 0, CLR_NONE, colourFg, mode);
			}

			//text
			if (group->cl.items[group->scanIndex]->type == CLCIT_DIVIDER) {
				RECT rc;
				rc.top = y + (dat->rowHeight >> 1);
				rc.bottom = rc.top + 2;
				rc.left = dat->leftMargin + indent * dat->groupIndent;
				rc.right = rc.left + ((clRect.right - rc.left - textSize.cx) >> 1) - 3;
				DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT);
				TextOut(hdcMem, rc.right + 3, y + ((dat->rowHeight - fontHeight) >> 1), group->cl.items[group->scanIndex]->szText,
					lstrlen(group->cl.items[group->scanIndex]->szText));
				rc.left = rc.right + 6 + textSize.cx;
				rc.right = clRect.right;
				DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT);
			}
Exemplo n.º 3
0
STDMETHODIMP CGfxRMI::Update()
{
	return S_OK;
#if 0
	HRESULT hr = S_OK;
	RECT rs, rd;

	SetRect(&rs,0,0,m_dwWidth,m_dwHeight);
	IntersectRect(&rs,&rs,&m_rectSrc);
	rd = m_rectDst;
	// handle alignment
#if 0
	if(m_Caps.dwAlignSizeDest>1)
	{
		rd.right &= ~(m_Caps.dwAlignSizeDest-1);
		rd.left &= ~(m_Caps.dwAlignSizeDest-1);
	}
#endif
	if(m_bScnClip)
	{
		IntersectRect(&rd,&rd,&m_rectScn);
		if(!EqualRect(&rd,&m_rectDst))
		{				// translate the clipped destination rectangle to clipping for source rectangle
			RECT rn;	// normalization 
			int wd,ws,hd,hs;

			rn = rd;
			OffsetRect(&rn,-m_rectDst.left,-m_rectDst.top);
			wd = m_rectDst.right-m_rectDst.left;
			hd = m_rectDst.bottom-m_rectDst.top;
			ws = rs.right-rs.left;
			hs = rs.bottom-rs.top;
			if(wd<=0 || hd<=0)
				SetRect(&rs,0,0,0,0);
			else
			{
				rn.left = rn.left*ws/wd;
				rn.right = rn.right*ws/wd;
				rn.top = rn.top*hs/hd;
				rn.bottom = rn.bottom*hs/hd;
				OffsetRect(&rn,rs.left,rs.top);
				IntersectRect(&rs,&rs,&rn);
			}
		}
	}
//	m_rectBltSrc = rs;
	if(m_rectScn.right>0 && m_rectScn.bottom>0 && !IsRectEmpty(&rd))
	{
		m_rectBltDst.left = (float)rd.left/m_rectScn.right;
		m_rectBltDst.right = (float)rd.right/m_rectScn.right;
		m_rectBltDst.top = (float)rd.top/m_rectScn.bottom;
		m_rectBltDst.bottom = (float)rd.bottom/m_rectScn.bottom;
	}
	else
	{
		m_rectBltDst.left = (float)0;
		m_rectBltDst.right = (float)1.;
		m_rectBltDst.top = (float)0;
		m_rectBltDst.bottom = (float)1.;
	}
	m_bUpdateBltDst = TRUE;
//	if(m_bLastShow==FALSE && m_bShow==FALSE)
//		return S_OK;
//	m_bLastShow = m_bShow;
	return SUCCEEDED(hr) ? S_OK : E_FAIL;
#endif
}
Exemplo n.º 4
0
// Assign a DirectShow YUV sample to a YUV_frame
extern HRESULT
YUV_frame_from_DirectShow(const CMediaType* pMT, BYTE* buff, YUV_frame* pFrame)
{
    BITMAPINFOHEADER*   pBmi;

    pBmi = GetBMI(pMT);
    if (pBmi == NULL)
        return E_UNEXPECTED;
    // set line stride
    if ((pBmi->biBitCount != 0) && ((pBmi->biBitCount & 7) == 0))
        // For 'normal' formats, biWidth is in pixels.
        // Expand to bytes and round up to a multiple of 4.
        pFrame->Y.lineStride = ((pBmi->biWidth * (pBmi->biBitCount / 8)) + 3) & ~3;
    else   // Otherwise, biWidth is in bytes.
        pFrame->Y.lineStride = pBmi->biWidth;
    // set pixel stride
    switch (pBmi->biCompression)
    {
    case FCC('YV12'):   case FCC('IF09'):   case FCC('YVU9'):   case FCC('IYUV'):
        // planar formats
        pFrame->Y.pixelStride = 1;
        break;
    case FCC('UYVY'):   case FCC('YUY2'):   case FCC('YVYU'):   case FCC('HDYC'):
        // multiplexed formats
        pFrame->Y.pixelStride = 2;
        break;
    default:
        return E_UNEXPECTED;
    }
    // set dimensions
    RECT* rcTarget = GetTargetRect(pMT);
    //  If rcTarget is empty, use the whole image.
    if (IsRectEmpty(rcTarget))
    {
        pFrame->Y.w = pBmi->biWidth;
        pFrame->Y.h = abs(pBmi->biHeight);
    }
    else    // rcTarget is NOT empty. Use a sub-rectangle in the image.
    {
        pFrame->Y.w = rcTarget->right - rcTarget->left;
        pFrame->Y.h = rcTarget->bottom - rcTarget->top;
        buff += (rcTarget->top * pFrame->Y.lineStride) +
                (rcTarget->left * pFrame->Y.pixelStride);
    }
    // set subsampling
    pFrame->U = pFrame->Y;
    switch (pBmi->biCompression)
    {
    case FCC('UYVY'):   case FCC('YUY2'):   case FCC('YVYU'):   case FCC('HDYC'):
        // horizontal 2:1
        pFrame->U.w = pFrame->Y.w / 2;
        pFrame->U.pixelStride = pFrame->Y.pixelStride * 2;
        break;
    case FCC('YV12'):   case FCC('IYUV'):
        // horizontal 2:1, vertical 2:1
        pFrame->U.w = pFrame->Y.w / 2;
        pFrame->U.h = pFrame->Y.h / 2;
        pFrame->U.lineStride = pFrame->Y.lineStride / 2;
        break;
    case FCC('IF09'):   case FCC('YVU9'):
        // horizontal 4:1, vertical 4:1
        pFrame->U.w = pFrame->Y.w / 4;
        pFrame->U.h = pFrame->Y.h / 4;
        pFrame->U.lineStride = pFrame->Y.lineStride / 4;
        break;
    default:
        return E_UNEXPECTED;
    }
    pFrame->V = pFrame->U;
    // set buffer pointers
    switch (pBmi->biCompression)
    {
    case FCC('UYVY'):   case FCC('HDYC'):
        pFrame->Y.buff = buff + 1;
        pFrame->U.buff = buff;
        pFrame->V.buff = buff + 2;
        break;
    case FCC('YUY2'):
        pFrame->Y.buff = buff;
        pFrame->U.buff = buff + 1;
        pFrame->V.buff = buff + 3;
        break;
    case FCC('YVYU'):
        pFrame->Y.buff = buff;
        pFrame->U.buff = buff + 3;
        pFrame->V.buff = buff + 1;
        break;
    case FCC('IYUV'):   case FCC('IF09'):   case FCC('YVU9'):
        pFrame->Y.buff = buff;
        pFrame->U.buff = pFrame->Y.buff + (pFrame->Y.lineStride * pFrame->Y.h);
        pFrame->V.buff = pFrame->U.buff + (pFrame->U.lineStride * pFrame->U.h);
        break;
    case FCC('YV12'):
        pFrame->Y.buff = buff;
        pFrame->V.buff = pFrame->Y.buff + (pFrame->Y.lineStride * pFrame->Y.h);
        pFrame->U.buff = pFrame->V.buff + (pFrame->V.lineStride * pFrame->V.h);
        break;
    default:
        return E_UNEXPECTED;
    }
    return S_OK;
}
Exemplo n.º 5
0
DWORD PrintABand (HDC hDC,
               LPRECT lpRectOut,
               LPRECT lpRectClip,
                 BOOL fDoText,
                 BOOL fDoGraphics,
                LPSTR lpDIBHdr,
                LPSTR lpDIBBits)
{
   int    nxLogPix, nyLogPix;
   RECT   rect;
   double dblXScaling, dblYScaling;
   DWORD  dwError = ERR_PRN_NONE;


   if (fDoGraphics)
      {
      nxLogPix = GetDeviceCaps (hDC, LOGPIXELSX);
      nyLogPix = GetDeviceCaps (hDC, LOGPIXELSY);

      dblXScaling = ((double) lpRectOut->right - lpRectOut->left) /
                     DIBWidth (lpDIBHdr);
      dblYScaling = ((double) lpRectOut->bottom - lpRectOut->top) /
                     DIBHeight (lpDIBHdr);


         // Now we set up a temporary rectangle -- this rectangle
         //  holds the coordinates on the paper where our bitmap
         //  WILL be output.  We can intersect this rectangle with
         //  the lpClipRect to see what we NEED to output to this
         //  band.  Then, we determine the coordinates in the DIB
         //  to which this rectangle corresponds (using dbl?Scaling).

      IntersectRect (&rect, lpRectOut, lpRectClip);

      if (!IsRectEmpty (&rect))
         {
         RECT rectIn;
         int  nPct;

         rectIn.left   = (int) ((rect.left - lpRectOut->left) /
                                 dblXScaling + 0.5);
         rectIn.top    = (int) ((rect.top  - lpRectOut->top) /
                                 dblYScaling + 0.5);
         rectIn.right  = (int) (rectIn.left + (rect.right  - rect.left) /
                                 dblXScaling + 0.5);
         rectIn.bottom = (int) (rectIn.top  +  (rect.bottom - rect.top) /
                                 dblYScaling + 0.5);

            // Could just always call StretchDIBits() below, but
            //  we want to give SetDIBitsToDevice() a work out, too!

         if ((rect.right - rect.left == rectIn.right - rectIn.left) &&
             (rect.bottom - rect.top == rectIn.bottom - rectIn.top))
            {
            if (!SetDIBitsToDevice (hDC,                            // DestDC
                                    rect.left,                      // DestX
                                    rect.top,                  // DestY
                                    rect.right - rect.left,    // DestWidth
                                    rect.bottom - rect.top,    // DestHeight
                                    rectIn.left,               // SrcX
                                    (int) DIBHeight (lpDIBHdr)-// SrcY
                                       rectIn.top -
                                       (rectIn.bottom - rectIn.top),
                                    0,                         // nStartScan
                                    (int) DIBHeight (lpDIBHdr),// nNumScans
                                    lpDIBBits,                 // lpBits
                                    (LPBITMAPINFO) lpDIBHdr,   // lpBitInfo
                                    DIB_RGB_COLORS))           // wUsage
               dwError |= ERR_PRN_SETDIBITSTODEV;
            }
         else
            {
            if (!StretchDIBits (hDC,                           // DestDC
                                rect.left,                     // DestX
                                rect.top,                      // DestY
                                rect.right - rect.left,        // DestWidth
                                rect.bottom - rect.top,        // DestHeight
                                rectIn.left,                   // SrcX
                                (int) DIBHeight (lpDIBHdr) -   // SrcY
                                   rectIn.top -
                                   (rectIn.bottom - rectIn.top),
                                rectIn.right - rectIn.left,    // SrcWidth
                                rectIn.bottom - rectIn.top,    // SrcHeight
                                lpDIBBits,                     // lpBits
                                (LPBITMAPINFO) lpDIBHdr,       // lpBitInfo
                                DIB_RGB_COLORS,                // wUsage
                                SRCCOPY))                      // dwROP
               dwError |= ERR_PRN_STRETCHDIBITS;
            }


            // Change percentage of print shown in abort dialog.

         nPct = MulDiv (rect.bottom,
                        100,
                        lpRectOut->bottom);
         ChangePrintPercent (nPct);
         }
      }

	 I_UNUSED(nyLogPix);
	 I_UNUSED(nxLogPix);
	 I_UNUSED(fDoText);

   return dwError;
}
Exemplo n.º 6
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	PTOON pToon = NULL;
	PDIB pdibSrc, pdibDst;
	LPOFFSCREEN lpOffScreen = NULL;

	if (IsRectEmpty(lpRect))
		return;
	PSTORY pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	// Draw the Bitmap
	rSrcArea = *lpRect;
	rDstArea = *lpRect;

	LPSCENE lpScene = CScene::GetScene(GetParent(hWindow));
	if (lpScene)
		lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
	 	if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
	}
	else
	{
		// see if there is a toon control
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		pdibSrc = pToon->GetStageDib();
		MapWindowPoints( hWindow, GetParent(hToon), (LPPOINT)&rDstArea, 2 );
 	}

	// create a dib to draw into
	pdibDst = new CDib();
	if (!pdibDst)
		return;
	if (!pdibDst->Create(pdibSrc->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pdibDst;
		return;
	}
	pdibDst->CopyColorTable(pdibSrc);
	
	// copy our color table into the dest dib
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	// draw in background
	pdibSrc->DibBlt( pdibDst,
					0, 0,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	rDstArea.left, rDstArea.top,
				 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				 	NO /*bTransparent*/ );

	// now draw in foreground
	RGBTRIPLE rgb;
	LPRGBTRIPLE lpRGB = NULL;
	if (dwStyle & BS_MASK)
	{
		STRING szColor;
		GetWindowText(hWindow, szColor, sizeof(szColor));
		AsciiRGB( szColor, &rgb );
		if (fHighlight)
		{
			// this relies on the fact that AsciiRGB replaces commas
			// with NULL terminators
			LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
			lp += lstrlen(lp) + 1; // passed green
			lp += lstrlen(lp) + 1; // passed blue to higlight color
			AsciiRGB(lp, &rgb);
			rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
		}
		else
			rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
		lpRGB = &rgb;
	}
	pStory->m_pDib->DibBlt( pdibDst,
				0, 0,
				rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				YES /*bTransparent*/, lpRGB, App.m_lpLut );

	pdibDst->DCBlt( hDC,
				rSrcArea.left, rSrcArea.top,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
			 	0, 0,
				rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top);

	delete pdibDst;
}
Exemplo n.º 7
0
static LRESULT CALLBACK MHeaderbarWndProc(HWND hwndDlg, UINT  msg, WPARAM wParam, LPARAM lParam)
{
	MHeaderbarCtrl* itc = (MHeaderbarCtrl *)GetWindowLongPtr(hwndDlg, 0);
	switch(msg) {
	case WM_NCCREATE:
		itc = new MHeaderbarCtrl; //(MHeaderbarCtrl*)mir_alloc(sizeof(MHeaderbarCtrl));
		if (itc == NULL)
			return FALSE;

		SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)itc);
		MHeaderbar_SetupColors(itc);

		{
			HWND hParent = GetParent(hwndDlg);
			RECT rcWnd; GetWindowRect(hwndDlg, &rcWnd);
			itc->controlsToRedraw = 0;
			itc->nControlsToRedraw = 0;
			for (HWND hChild = FindWindowEx(hParent, NULL, NULL, NULL); hChild; hChild = FindWindowEx(hParent, hChild, NULL, NULL))
			{
				if (hChild != hwndDlg)
				{
					RECT rcChild; GetWindowRect(hChild, &rcChild);
					RECT rc;
					IntersectRect(&rc, &rcChild, &rcWnd);
					if (!IsRectEmpty(&rc))
					{
						++itc->nControlsToRedraw;
						itc->controlsToRedraw = (HWND *)mir_realloc(itc->controlsToRedraw, sizeof(HWND) * itc->nControlsToRedraw);
						itc->controlsToRedraw[itc->nControlsToRedraw - 1] = hChild;
					}
				}
			}
		}

		break;

	case WM_SETFONT:
		itc->hFont = (HFONT)wParam;
		break;

	case WM_SIZE:
		GetClientRect(hwndDlg, &itc->rc);
		itc->width = itc->rc.right-itc->rc.left;
		itc->height = itc->rc.bottom-itc->rc.top;
		return TRUE;

	case WM_THEMECHANGED:
	case WM_STYLECHANGED:
		MHeaderbar_SetupColors(itc);
		return TRUE;

	case WM_LBUTTONDOWN:
		SendMessage(GetParent(hwndDlg), WM_SYSCOMMAND, 0xF012, 0);
		return 0;

	case WM_SETICON:
		if (wParam < 3) {
			itc->hIcon = (HICON)lParam;
			InvalidateRect(hwndDlg, NULL, FALSE);
		}
		break;

	case WM_ERASEBKGND:
		return 1;

	case WM_NCPAINT:
		InvalidateRect(hwndDlg, NULL, FALSE);
		break;

	case WM_PAINT:
		MHeaderbar_OnPaint(hwndDlg, itc, msg, wParam, lParam);
		break;

	case WM_DESTROY:
		delete itc;
		break;
	}
	return DefWindowProc(hwndDlg, msg, wParam, lParam);
}
Exemplo n.º 8
0
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam )
/***********************************************************************/
{
FNAME szFileName;
LPFRAME lpFrame;
LPOBJECT lpObject, lpBase;
RECT rect, rMask, rTemp, rAll;
HWND hWnd;
STRING szString;
int i, idFileType, x, y, dx, dy;
BOOL fDoZoom, bPrint, fHasZoom;
LPSTR lpszCmdLine;
HGLOBAL hMem;
ITEMID idDataType;
DWORD dwReturn;
int NewShape;
UINT wID;

SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ );
/*
	WIN16:	ID          = wParam
			ctrl handle = LOWORD(lParam)
			notify code = HIWORD(lParam)

	WIN32:	ID          = LOWORD(wParam)
			ctrl handle = lParam
			notify code = HIWORD(wParam)
*/

#ifdef WIN32
	wID = LOWORD(wParam);
#else
	wID = wParam;
#endif

switch (wID)
	{
	case IDM_EXIT:
	DeactivateTool();
	PostMessage( hWndAstral, WM_CLOSE, 0, 0L);
    Delay (750);
	break;

	case IDM_CLOSE:
	DeactivateTool();
	/* Check to see if the image needs to be saved */
	if ( !ConfirmClose(NO,NO) )
		break;
	CloseImage( NO, lpImage ); // Close the active image
	break;

	case IDM_ABOUT:
	/* Bring up the modal 'About' dialog box */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc);
	break;

	case IDM_NEXTPAGE:
	if ( !lpImage )
		break;
	DeactivateTool();
	SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L );
	break;

	case IDM_NEW:
	DeactivateTool();
	SoundStartResource( "magic01", NO, NULL );
	AstralCursor( IDC_WAIT );
	New( Control.NewWidth, Control.NewHeight, Control.NewResolution,
		Control.NewDepth );
	AstralCursor( NULL );
	break;

	case IDM_OPEN:
	DeactivateTool();
	/* Bring up the modal 'File Open' box */
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN,
		Save.FileType, szFileName, NO )) )
		break;
	idFileType = LOWORD( dwReturn );
	Save.FileType = idFileType;
	PutDefaultInt( "FileType", idFileType - IDN_TIFF );
	AstralImageLoad( idFileType, szFileName, MAYBE, YES );
	break;

	case IDM_ALTOPEN:
	DeactivateTool();
	// Command line sent from a second instance prior to it closing
	/* If the caller passed in a file name, try to load it or print it */
	if ( !(lpszCmdLine = (LPSTR)lParam) )
		break;
	HandleCommandLine( hWindow, lpszCmdLine, &bPrint );
	break;

	case IDM_SAVE:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEAS:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVESPECIAL:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEWALLPAPER:
	DeactivateTool();
	SaveWallpaper( "CRAYOLA", NO/*fTiled*/ );
	break;

	case IDM_REVERT:
	if ( !lpImage )
		break;
	DeactivateTool();
	if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out
		break;
	if ( ImgChanged(lpImage) )
		{
		/* Check to see if its OK to trash changes */
		if ( AstralOKCancel(IDS_OKTOREVERT,
				(LPSTR)lpImage->CurFile) == IDCANCEL )
			break;
		}
	lstrcpy( szFileName, lpImage->CurFile );
	idFileType = lpImage->FileType;
	fDoZoom = IsZoomed(lpImage->hWnd);
	fHasZoom = Window.fHasZoom;
	CloseImage( NO, lpImage ); // Close the active image
	if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) )
		break;
	break;

	case IDM_RECALLIMAGE0:
	case IDM_RECALLIMAGE1:
	case IDM_RECALLIMAGE2:
	case IDM_RECALLIMAGE3:
	case IDM_RECALLIMAGE4:
	case IDM_RECALLIMAGE5:
	case IDM_RECALLIMAGE6:
	case IDM_RECALLIMAGE7:
	case IDM_RECALLIMAGE8:
	case IDM_RECALLIMAGE9:
	DeactivateTool();
	GetMenuString( GetMenu(hWindow), wID,
		szFileName, sizeof(szFileName), MF_BYCOMMAND );
	i = 0;
	while ( szFileName[i] && szFileName[i] != ' ' )
		i++; // Skip over the numeric id in the string (3. junk.tif)
	lstrcpy(szString, &szFileName[i+1]);
	GetRecallFileName(szString);
	AstralImageLoad( NULL, szString, MAYBE, YES );
	break;

	case IDM_PRINT:
	if ( !lpImage )
		break;
	DeactivateTool();
	AstralCursor( IDC_WAIT );
	DoPrintSizeInits();
	SoundStartResource( "print", YES, NULL );
	PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL );
	SoundStop();
	AstralCursor( NULL );
	break;

	case IDM_PRINTSETUP:
	/* Bring up the setup dialog box for the active printer */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP,
		DlgPrintSetupProc);
	break;

	case IDC_SOUND:
	SoundToggle();
	break;

	case IDM_UNDO:
	if ( !lpImage )
		break;
	DeactivateTool();
	ImgEditUndo(lpImage, YES, NO);
	break;

	case IDM_CUT:
	case IDM_COPY:
	if ( !lpImage )
		break;
	DeactivateTool();

	// Create the clipboard files from the image
	ProgressBegin(1, IDS_PROGCOPY);
	if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) )
		{
		ProgressEnd();
		Message(IDS_EMEMALLOC);
		break;
		}
	ProgressEnd();

	OpenClipboard(hWindow);
	EmptyClipboard();

	// Passing a NULL data handle in SetClipboardData() means that
	// the data will be requested in a WM_RENDERFORMAT message
	hMem = ConstructObject( lpImage,
		IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask );
	if ( pOLE )
		{ // Any data put on before Native will become staticly copied
		SetClipboardData( pOLE->cfNative, NULL );
		SetClipboardData( pOLE->cfOwnerLink, hMem );
		}
	SetClipboardData( CF_DIB, NULL );
	if ( Control.DoPicture )
		SetClipboardData( CF_METAFILEPICT, NULL );
	if ( Control.DoBitmap )
		SetClipboardData( CF_BITMAP, NULL );
	SetClipboardData( CF_PALETTE, NULL );
	SetClipboardData( Control.cfImage, NULL );
	if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled )
		{ // ObjectLink is retrieved during a Paste Link...
		SetClipboardData( pOLE->cfObjectLink, hMem );
		}
	CloseClipboard();
	if ( wID == IDM_COPY )
		break;

	// else fall through to IDM_DELETE

	case IDM_DELETE:
	if ( !lpImage )
		break;
	{
	COLORINFO ColorInfo;

	DeactivateTool();
	ColorInfo.gray   = 255;
	SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY );
	TintFill( lpImage, &ColorInfo, 255, MM_NORMAL,
		wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE );
	}
	break;

	case IDM_PASTE:
	if ( !lpImage )
		break;

	case IDM_PASTEASNEW:
	if ( !OpenClipboard(hWndAstral) )
		{
		Message( IDS_ECLIPOPEN );
		break;
		}
	if ( !IsClipboardFormatAvailable(CF_DIB) &&
	     !IsClipboardFormatAvailable(CF_BITMAP) &&
	     !IsClipboardFormatAvailable(Control.cfImage) )
		{
		Message( IDS_ECLIPOPEN );
		CloseClipboard();
		break;
		}
	CloseClipboard();

	DeactivateTool();
	// First put clipboard contents into a file(s)
	AstralCursor(IDC_WAIT);
	if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) )
		{
		AstralCursor(NULL);
		Message(IDS_EMEMALLOC);
		break;
		}
	if ( wID == IDM_PASTE )
		{
		ProgressBegin(1, IDS_PROGPASTECLIP);
		TransformObjectsStart( YES/*fNewObject*/ );
        if ( ImgCreateClipInObject( lpImage, NO ) )
			;
		ProgressEnd();
		}
	else
	if ( wID == IDM_PASTEASNEW )
		{
		if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1,
			 &idDataType, &idFileType) )
			{
			if ( NewImageWindow(
				NULL,			// lpOldFrame
				NULL,			// Name
				lpFrame, 		// lpNewFrame
				idFileType,		// lpImage->FileType
				idDataType,		// lpImage->DataType
				FALSE,			// New view?
				IMG_DOCUMENT,	// lpImage->DocumentType
				NULL,			// lpImage->ImageName
				MAYBE
				) )
					lpImage->fChanged = YES;
			}
		}
	break;

	case IDM_ESCAPE:
	if (!lpImage)
		break;
	if (lpImage->hWnd == hZoomWindow)
		break;
	if ( Tool.bActive && Tool.lpToolProc )
		DestroyProc( lpImage->hWnd, 1L );
	break;

	case IDM_SIZEUP:
	case IDM_SIZEDOWN:
	if (!Retouch.hBrush)
		break;				 
	SetFocus( hWindow ); // Take focus away from any controls
	if ( Retouch.BrushShape == IDC_BRUSHCUSTOM )
		break;
	if ( wID == IDM_SIZEUP )
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 ))
    		Retouch.BrushSize += 2;
        else        
    		Retouch.BrushSize++;
    }
	else	
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) 
    		Retouch.BrushSize -= 2;
        else        
    		Retouch.BrushSize--;
    }
	if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE )
		{
		Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE);
		MessageBeep(0);
		break;
		}
	if (lpImage)
		DisplayBrush(0, 0, 0, OFF);
	SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize);
	if (lpImage && Window.hCursor == Window.hNullCursor)
		DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize );
	break;

	case IDM_SHAPEUP:
	case IDM_SHAPEDOWN:
	if (!Retouch.hBrush)
		break;
	SetFocus( hWindow ); // Take focus away from any controls
	NewShape = Retouch.BrushShape;
	if ( wID == IDM_SHAPEUP )
		NewShape++;
	else	NewShape--;
	if ( NewShape > IDC_BRUSHCUSTOM )
		NewShape = IDC_BRUSHCIRCLE;
	if ( NewShape < IDC_BRUSHCIRCLE )
		NewShape = IDC_BRUSHCUSTOM;
	if (lpImage)
	 	DisplayBrush(0, 0, 0, OFF);
	if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush))
		{
		NewShape = IDC_BRUSHCIRCLE;
		SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush);
		}
	Retouch.BrushShape = NewShape;
	if (lpImage && Window.hCursor == Window.hNullCursor)
	 	DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		{
		CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE,
			IDC_BRUSHCUSTOMNEW, Retouch.BrushShape );
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
		}
	break;

	case IDM_MOVEUP:
	case IDM_MOVEDOWN:
	case IDM_MOVELEFT:
	case IDM_MOVERIGHT:
	if (!lpImage)
		break;
	lpBase = ImgGetBase(lpImage);
	if (ImgGetSelObject(lpImage, NULL) == lpBase)
		break;
	dx = dy = 0;
	if (wID == IDM_MOVEUP)
		--dy;
	if (wID == IDM_MOVEDOWN)
		++dy;
	if (wID == IDM_MOVELEFT)
		--dx;
	if (wID == IDM_MOVERIGHT)
		++dx;
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&rect, dx, dy);
		if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect))
			break;
		}
	if (lpObject)
		break;
	AstralSetRectEmpty(&rAll);
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&lpObject->rObject, dx, dy);
		AstralUnionRect(&rAll, &rAll, &lpObject->rObject);
		if (!lpObject->Pixmap.fNewFrame &&
				EqualRect(&rect, &lpObject->rUndoObject))
			lpObject->rUndoObject = lpObject->rObject;
		UpdateImage(&rect, TRUE);
		UpdateImage(&lpObject->rObject, TRUE);
		}
	if (wID == IDM_MOVEUP)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.top;
		}
	else
	if (wID == IDM_MOVEDOWN)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.bottom;
		}
	else
	if (wID == IDM_MOVELEFT)
		{
		x = rAll.left;
		y = (rAll.top + rAll.bottom)/2;
		}
	else
	if (wID == IDM_MOVERIGHT)
		{
		x = rAll.right;
		y = (rAll.top + rAll.bottom)/2;
		}
	File2Display(&x, &y);
	AutoScroll(lpImage->hWnd, x, y);
	AstralUpdateWindow(lpImage->hWnd);
	DisplayInfo(-1, &rAll);
	break;

	case IDM_LASTTOOL:
	DeactivateTool();
	if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) )
		SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L);
	break;

	case IDM_PREF:
	// prevent problems if running animations and they change
	// the wave mix dll setting in preferences
	StopAnimation();
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc );
	break;

	case IDC_VIEWLAST: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	RevertLastView();
	break;

//	case IDC_VIEWFULL: // duplicate of function in the view ribbon
//	if ( !lpImage )
//		break;
//	AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc );
//	break;

	case IDC_VIEWALL: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	ViewAll();
	break;

	case IDC_ZOOMIN: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDC_ZOOMOUT: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDM_HELP:
	Control.Hints = !Control.Hints;
	PutDefInt (Control.Hints,Control.Hints);
	break;

	default:
	return( FALSE );
	}

return( TRUE );
}
Exemplo n.º 9
0
void AGScreen::Paint (CG16bitImage &Dest)

//	Paint
//
//	Paint the whole screen.
//
//	Dest is the entire display area; its origin is 0,0.

	{
	if (!IsRectEmpty(&m_rcInvalid))
		{
		int i;

		//	Convert to Window coordinates

		RECT rcUpdate = m_rcInvalid;
		OffsetRect(&rcUpdate, m_rcRect.left, m_rcRect.top);

		//	Clip appropriately. Note that Dest is always in
		//	window coordinates.

		Dest.SetClipRect(rcUpdate);

		//	Blank the screen

		Dest.Fill(rcUpdate.left, rcUpdate.top, RectWidth(rcUpdate), RectHeight(rcUpdate), CG16bitImage::RGBValue(0,0,0));

		//	Let each area paint

		for (i = 0; i < GetAreaCount(); i++)
			{
			AGArea *pArea = GetArea(i);

			//	m_rcInvalid is in Screen coordinates, and so is the rect
			//	for each area. The intersection is the portion of the
			//	area's rect that is invalid.

			RECT rcIntersect;
			if (pArea->IsVisible()
					&& ::IntersectRect(&rcIntersect, &m_rcInvalid, &pArea->GetRect()))
				{
				//	Calculate the rect of the area relative to the Window

				RECT rcArea = pArea->GetRect();
				OffsetRect(&rcArea, m_rcRect.left, m_rcRect.top);

				//	Clip appropriately

				OffsetRect(&rcIntersect, m_rcRect.left, m_rcRect.top);
				Dest.SetClipRect(rcIntersect);

				//	Paint

				pArea->Paint(Dest, rcArea);
				}
			}

		//	Reset the invalid rect

		memset(&m_rcInvalid, 0, sizeof(m_rcInvalid));
		Dest.ResetClipRect();
		}
	}
Exemplo n.º 10
0
/*
 * OnInitDialog()
 */
BOOL mfd_OnInitDialog(HWND mtfDlg, HWND focusCtrl, LPARAM lParam)
{
    HWND ctrl;
    int i;
    SPECIALLCDINIT noteLcdInit = { IDC_MT_NOTE_1,  3, 13, 109
        , Prog_keyNameStrings[13], NULL };
    NUMLCDINIT fineLcdInit = { IDC_MT_FINE_1,  3,  0,   63, -31, NULL };
    NUMLCDINIT fullLcdInit = { IDC_MT_FULL_1,  4,  0, 6143,   0, NULL };
    _TUCHAR noteName[5];

    mfd_dlgData.wnd = Prog_mtfDlg = mtfDlg;
    /*
     * Adjust the window position.
     */
    if (IsRectEmpty(&Prog_mtfDlgPlacement.rcNormalPosition)) {
        Window_Center(mtfDlg, mfd_parentWnd);
        GetWindowPlacement(mtfDlg, &Prog_mtfDlgPlacement);
    }
    /*
     * Set up dialog controls.
     */
    for (i = 0; i < mfd_initCnt; i++) {
        int topOffset = 34 * i;

        /*
         * Create note label.
         */
        KybdCtrl_KeyToText(i, noteName);
        ctrl = CreateWindow(
                _T("Static")                           /* window class */
                , noteName                             /* caption text */
                , WS_CHILD | WS_GROUP | WS_VISIBLE     /* styles */
                    | SS_LEFT
                , 3, 7 + topOffset                    /* left, top */
                , 26, 13                               /* width, height */
                , mtfDlg                               /* parent window */
                , (HMENU) IDC_STATIC                   /* control ID */
                , Prog_instance                        /* program instance */
                , NULL                                 /* creation data */
            );
        if (!ctrl) {
            Error_LastErrorF(_T("Error creating %s note label"), noteName);
            return FALSE;
        }
        SetWindowFont(ctrl, Prog_tahomaFont, FALSE);
        /*
         * Create Note LCD.
         */
        ctrl = CreateWindow(
                _T("LcdCtrl")                          /* window class */
                , NULL                                 /* caption text */
                , WS_CHILD | WS_TABSTOP | WS_VISIBLE   /* styles */
                    | LCS_SMALL | LCS_TEXT | LCS_LEFT_SB
                , 32, topOffset                        /* left, top */
                , 324, 13                              /* width, height */
                , mtfDlg                               /* parent window */
                , (HMENU) (IDC_MT_NOTE_1 + (i << 1))   /* control ID */
                , Prog_instance                        /* program instance */
                , NULL                                 /* creation data */
            );
        if (!ctrl) {
            Error_LastErrorF(_T("Error creating %s note LCD"), noteName);
            return FALSE;
        }
        LcdCtrl_SpecialInit(ctrl, &noteLcdInit);
        KeyNav_SubclassLcdCtrl(ctrl);
        /*
         * Create fine LCD.
         */
        ctrl = CreateWindow(
                _T("LcdCtrl")                          /* window class */
                , NULL                                 /* caption text */
                , WS_CHILD | WS_TABSTOP | WS_VISIBLE   /* styles */
                    | LCS_SMALL | LCS_NUMERIC | LCS_SHOWPLUS | LCS_LEFT_SB
                , 360, topOffset                       /* left, top */
                , 143, 13                              /* width, height */
                , mtfDlg                               /* parent window */
                , (HMENU) (IDC_MT_FINE_1 + (i << 1))   /* control ID */
                , Prog_instance                        /* program instance */
                , NULL                                 /* creation data */
            );
        if (!ctrl) {
            Error_LastErrorF(_T("Error creating %s fine LCD"), noteName);
            return FALSE;
        }
        LcdCtrl_NumInit(ctrl, &fineLcdInit);
        KeyNav_SubclassLcdCtrl(ctrl);
        /*
         * Create full range LCD.
         */
        ctrl = CreateWindow(
                _T("LcdCtrl")                          /* window class */
                , NULL                                 /* caption text */
                , WS_CHILD | WS_TABSTOP | WS_VISIBLE   /* styles */
                    | LCS_SMALL | LCS_NUMERIC | LCS_LEFT_SB
                , 32, 15 + topOffset                   /* left, top */
                , 471, 13                              /* width, height */
                , mtfDlg                               /* parent window */
                , (HMENU) (IDC_MT_FULL_1 + i)          /* control ID */
                , Prog_instance                        /* program instance */
                , NULL                                 /* creation data */
            );
        if (!ctrl) {
            Error_LastErrorF(_T("Error creating %s full range LCD"), noteName);
            return FALSE;
        }
        LcdCtrl_NumInit(ctrl, &fullLcdInit);
        KeyNav_SubclassLcdCtrl(ctrl);
        /*
         * Create frequency static control.
         */
        ctrl = CreateWindow(
                _T("Static")                           /* window class */
                , NULL                                 /* caption text */
                , WS_CHILD | WS_VISIBLE | SS_RIGHT     /* styles */
                    | SS_SUNKEN
                , 508, 7 + topOffset                   /* left, top */
                , 40, 16                               /* width, height */
                , mtfDlg                               /* parent window */
                , (HMENU) (IDC_MT_FREQ_1 + i)          /* control ID */
                , Prog_instance                        /* program instance */
                , NULL                                 /* creation data */
            );
        if (!ctrl) {
            Error_LastErrorF(_T("Error creating %s frequency display"), noteName);
            return FALSE;
        }
        SetWindowFont(ctrl, Prog_tahomaFont, FALSE);
    }
    /*
     * Set up the undo infrastructure.
     */
    mfd_dlgData.menu = GetMenu(mtfDlg);
    mfd_dlgData.undo = Undo_Create();
    /*
     * Init control values.
     */
    MTGen_InitControlValues(&mfd_dlgData);
    /*
     * Set up the scrolling dialog module.
     */
    if (!(mfd_dialog = Dialog_Create(mtfDlg)))
        return FALSE;
    Dialog_UpdateScrollBars(mfd_dialog);
    /*
     * Adjust and display the window.
     */
#define RC Prog_mtfDlgPlacement.rcNormalPosition
    MoveWindow(mtfDlg, RC.left, RC.top
            , RECT_W(RC) + GetSystemMetrics(SM_CXHSCROLL)
            , RECT_H(RC) + GetSystemMetrics(SM_CYVSCROLL), TRUE);
    MoveWindow(mtfDlg, RC.left, RC.top, RECT_W(RC), RECT_H(RC), TRUE);
#undef RC
    ShowWindow(mtfDlg, SW_SHOWNORMAL);

    return TRUE;
}
Exemplo n.º 11
0
LRESULT OnKeyDown(HWND hWnd,WPARAM wParam,LPARAM lParam)
{
	BOOL bShift, bControl;
	int dx,dy;
	RECT drt,crt,irt;
	BOOL bAction=TRUE;

	if (NowSel == -1) {
		return 0;
	}
	
	bShift=((GetKeyState(VK_SHIFT) & 0x8000) != 0); 
	bControl=((GetKeyState(VK_CONTROL) & 0x8000) != 0);
	if (bControl) {
		dx=1;
		dy=1;
	} else {
		dx=GridX;
		dy=GridY;
	}
	drt=arObj[NowSel]->rt;

	if (bShift == FALSE) {
		switch(wParam) {
		case VK_LEFT:
			OffsetRect(&drt,-dx,0);
			break;
		case VK_RIGHT:
			OffsetRect(&drt,dx,0);
			break;
		case VK_UP:
			OffsetRect(&drt,0,-dy);
			break;
		case VK_DOWN:
			OffsetRect(&drt,0,dy);
			break;
		default:
			bAction=FALSE;
			break;
		}
	} else {
		switch(wParam) {
		case VK_LEFT:
			if (drt.right > drt.left + 10) {
				drt.right -= dx;
			}
			break;
		case VK_RIGHT:
			drt.right += dx;
			break;
		case VK_UP:
			if (drt.bottom > drt.top + 10) {
				drt.bottom -=dy;
			}
			break;
		case VK_DOWN:
			drt.bottom += dy;
			break;
		default:
			bAction=FALSE;
			break;
		}
	}

	if (bAction) {
		GetClientRect(hWnd,&crt);
		InflateRect(&crt,-10,-10);
		IntersectRect(&irt,&crt,&drt);
		if (!IsRectEmpty(&irt)) {
			arObj[NowSel]->rt=drt;
			InvalidateRect(hWnd,NULL,TRUE);
		}
	}
	return 0;
}
Exemplo n.º 12
0
BOOL GUIAPI SubtractClipRect (PCLIPRGN pRgn, const RECT* pRect)
{
    PCLIPRECT pCRect, pSaved, pTemp;
    RECT rc[4], rcTemp, rcInflated;
    int nCount;
    PRECT src, erc;
    int i;

    if (IsRectEmpty (pRect))
        return FALSE;

    rcInflated = *pRect;
    erc = &rcInflated;

    NormalizeRect (erc);

    if (!DoesIntersect(&pRgn->rcBound, erc)) {
        return FALSE;
    }

    pCRect = pRgn->head;
    while (pCRect) {

        src = &pCRect->rc;
        if (!IntersectRect(&rcTemp, src, erc)) {
            pCRect = pCRect->next;
            continue;
        }

        pSaved = pCRect->next;

        nCount = 0;
        if(erc->top > src->top)
        {
            rc[nCount].left  = src->left;
            rc[nCount].top   = src->top;
            rc[nCount].right = src->right;
            rc[nCount].bottom = erc->top;
            nCount++;

            src->top = erc->top;
        }

        if(erc->bottom < src->bottom)
        {
            rc[nCount].top  = erc->bottom;
            rc[nCount].left   = src->left;
            rc[nCount].right = src->right;
            rc[nCount].bottom = src->bottom;
            nCount++;
 
            src->bottom = erc->bottom;
        }

        if(erc->left > src->left)
        {
            rc[nCount].left  = src->left;
            rc[nCount].top   = src->top;
            rc[nCount].right = erc->left;
            rc[nCount].bottom = src->bottom;
            nCount++;
        }

        if(erc->right < src->right)
        {
            rc[nCount].left  = erc->right;
            rc[nCount].top   = src->top;
            rc[nCount].right = src->right;
            rc[nCount].bottom = src->bottom;
            nCount++;
        }

        if (nCount == 0)
            SetRectEmpty (&pCRect->rc);
        else if(nCount > 0)
            pCRect->rc = rc[0];

        for(i = 1; i<nCount; i++)
        {
            pTemp = ClipRectAlloc (pRgn->heap); 
            pTemp->rc = rc[i];
            pCRect->next = pTemp;
            pCRect = pTemp;
        }

        pCRect->next = pSaved;

        pCRect = pSaved;
    }

    EvaluateBoundRect (pRgn);

    return TRUE;
}
HRESULT CViewProps::DisplayProps()
{
	if(!m_View) return E_FAIL;

	CProjectDoc* Doc = m_View->GetDocument();
	if(!Doc || !Doc->m_Settings) return E_FAIL;


	CPLPropertyEdit* pEdit;
	CPLPropertyCombo* pCombo;
	CPLPropertyEditEx* pEditEx;
	CPLCategory* cat;
	CPLPropertyColor* pColor;

	CString str;


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("startup", LOC("/str0001/Startup settings"));
	
	pEdit = new CPLPropertyEdit("resolution-x", LOC("/str0002/Resolution - width"));
	pEdit->m_HelpFile = "resolution";
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 320, 3000);
	str.Format("%d", Doc->m_Settings->m_ResolutionWidth);
	pEdit->SetValue(str);

	pEdit = new CPLPropertyEdit("resolution-y", LOC("/str0003/Resolution - height"));
	pEdit->m_HelpFile = "resolution";
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 200, 3000);
	str.Format("%d", Doc->m_Settings->m_ResolutionHeight);
	pEdit->SetValue(str);

	pEdit = new CPLPropertyEdit("reg-path", LOC("/str0005/Registry path"));
	m_PropList.AddProperty(cat, pEdit);
	if(Doc->m_Settings->m_RegPath) pEdit->SetValue(Doc->m_Settings->m_RegPath);
	else pEdit->SetValue("");
/*
	pCombo = new CPLPropertyCombo("require-accel", LOC("/str0006/Require 3D accel."));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_RequireAcceleration?LOC("/str1000/Yes"):LOC("/str1001/No"));
*/
	pCombo = new CPLPropertyCombo("require-sound", LOC("/str1144/Require sound"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_RequireSound?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("hwtl-mode", LOC("/str1145/Hardware T&&L"));
	pCombo->AddValue(LOC("/str1146/don't use"), "0");
	pCombo->AddValue(LOC("/str1147/use when available"), "1");
	pCombo->AddValue(LOC("/str1148/ask user"), "2");
	m_PropList.AddProperty(cat,  pCombo);
	switch(Doc->m_Settings->m_TLMode)
	{
	case 0:
		pCombo->SetValue("0");
		break;
	case 2:
		pCombo->SetValue("2");
		break;
	default:
		pCombo->SetValue("1");
	}	

	pCombo = new CPLPropertyCombo("use-d3d9", LOC("/str1149/Use Direct3D 9"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_D3D9?LOC("/str1000/Yes"):LOC("/str1001/No"));


	pCombo = new CPLPropertyCombo("allow-windowed", LOC("/str0007/Allow windowed"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowWindowed?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-advanced", LOC("/str1115/Allow 3D settings"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowAdvanced?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-desktop-res", LOC("/str1186/Allow desktop resolution"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowDesktopRes?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-access-tab", LOC("/str1126/Allow accessibility"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowAccessTab?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-about-tab", LOC("/str1127/Allow about tab"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_AllowAboutTab?LOC("/str1000/Yes"):LOC("/str1001/No"));


	pEditEx = new CPLPropertyEditEx("string-table", LOC("/str0008/String table"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	pEditEx->SetValue(Doc->m_Settings->m_StringTableFilename);


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("game", LOC("/str0009/Game settings"));

	pEdit = new CPLPropertyEdit("caption", LOC("/str0010/Caption"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValue(Doc->Game->m_Caption[0]);

	pEdit = new CPLPropertyEdit("name", LOC("/str0011/Name"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValue(Doc->Game->m_Name);

	pEditEx = new CPLPropertyEditEx("startup-scene", LOC("/str1087/Startup scene"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_StartupScene)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_StartupScene);

	pEditEx = new CPLPropertyEditEx("scripts", LOC("/str0012/Scripts"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonScripts, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->Game->m_Scripts.GetSize()==0) str = LOC("/str0013/[NO SCRIPTS]");
	else{
		str.Format("[%d %s]", Doc->Game->m_Scripts.GetSize(), Doc->Game->m_Scripts.GetSize()>1?LOC("/str0014/scripts"):LOC("/str0015/script"));
	}
	pEditEx->SetValue(str);


	pCombo = new CPLPropertyCombo("subtitles", LOC("/str0017/Speech subtitles"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_EdGame->m_Subtitles?LOC("/str1000/Yes"):LOC("/str1001/No"));


	pCombo = new CPLPropertyCombo("video-subtitles", LOC("/str0018/Video subtitles"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_EdGame->m_VideoSubtitles?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pEdit = new CPLPropertyEdit("subtitles-speed", LOC("/str0019/Subtitles speed"));
	m_PropList.AddProperty(cat, pEdit);
	CString val;
	val.Format("%d", Doc->m_Settings->m_EdGame->m_SubtitlesSpeed);
	pEdit->SetValue(val);

	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 10, 1000);


	pEditEx = new CPLPropertyEditEx("system-font", LOC("/str0020/System font"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_SystemFont)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_SystemFont);

	pEditEx = new CPLPropertyEditEx("video-font", LOC("/str0021/Video font"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_VideoFont)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_VideoFont);

	pEditEx = new CPLPropertyEditEx("cursor", LOC("/str0022/Cursor"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_Cursor)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_Cursor);

	pEditEx = new CPLPropertyEditEx("active-cursor", LOC("/str0023/Active cursor"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_ActiveCursor)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_ActiveCursor);

	pEditEx = new CPLPropertyEditEx("nonint-cursor", LOC("/str0024/Nonint.cursor"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_NoninteractiveCursor)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_NoninteractiveCursor);


	pEditEx = new CPLPropertyEditEx("inventory", LOC("/str0025/Inventory window"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_InventoryFile)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_InventoryFile);


	pEditEx = new CPLPropertyEditEx("response", LOC("/str0026/Response window"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_ResponseFile)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_ResponseFile);


	pEditEx = new CPLPropertyEditEx("items", LOC("/str0027/Items definition"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_ItemsFile)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_ItemsFile);


	pCombo = new CPLPropertyCombo("talk-skip", LOC("/str0028/Talk lines skipped by"));
	pCombo->AddValue(LOC("/str0029/left mouse button"), "left");
	pCombo->AddValue(LOC("/str0030/right mouse button"), "right");
	pCombo->AddValue(LOC("/str0031/both mouse buttons"), "both");
	m_PropList.AddProperty(cat,  pCombo);

	if(Doc->m_Settings->m_EdGame->m_TalkSkipButton==TALK_SKIP_RIGHT)
		pCombo->SetValue("right");
	else if(Doc->m_Settings->m_EdGame->m_TalkSkipButton==TALK_SKIP_BOTH)
		pCombo->SetValue("both");
	else
		pCombo->SetValue("left");


	pEditEx = new CPLPropertyEditEx("viewport", LOC("/str0032/Scene viewport"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonViewport, this);
	m_PropList.AddProperty(cat, pEditEx);

	RECT* rc = &Doc->m_Settings->m_EdGame->m_SceneViewport;
	if(IsRectEmpty(rc)) str = LOC("/str0033/[fullscreen]");
	else{		
		str.Format(CString("[") + LOC("/str0034/Pos:") + "%d,%d  " + LOC("/str0035/Size:") + "%dx%d]", rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top);
	}
	pEditEx->SetValue(str);


	pEditEx = new CPLPropertyEditEx("guid", LOC("/str1151/GUID"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonGUID, this);
	m_PropList.AddProperty(cat, pEditEx);

	if(Doc->m_Settings->m_GameGUID==GUID_NULL) str = "";
	else
	{
		LPOLESTR  olestr;
		StringFromIID(Doc->m_Settings->m_GameGUID, &olestr);
		str = CString(olestr);
		CoTaskMemFree(olestr);
	}
	pEditEx->SetValue(str);


	pEditEx = new CPLPropertyEditEx("compat", LOC("/str1177/Compatibility"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonCompat, this);
	m_PropList.AddProperty(cat, pEditEx);


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("save", LOC("/str1091/Saved games"));
	cat->m_Expanded = false;

	pCombo = new CPLPropertyCombo("personal-save", LOC("/str0016/Personal savegames"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_EdGame->m_PersonalizedSave?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pEdit = new CPLPropertyEdit("save-path", LOC("/str1116/Save directory"));
	m_PropList.AddProperty(cat, pEdit);
	if(Doc->m_Settings->m_EdGame->m_LocalSaveDir) pEdit->SetValue(Doc->m_Settings->m_EdGame->m_LocalSaveDir);
	else pEdit->SetValue("");


	pEdit = new CPLPropertyEdit("thumbnail-width", LOC("/str1092/Thumbnail width"));
	pEdit->m_HelpFile = "thumbnail";
	m_PropList.AddProperty(cat, pEdit);	
	val.Format("%d", Doc->m_Settings->m_EdGame->m_ThumbnailWidth);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 400);


	pEdit = new CPLPropertyEdit("thumbnail-height", LOC("/str1093/Thumbnail height"));
	pEdit->m_HelpFile = "thumbnail";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_ThumbnailHeight);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 400);

	pEdit = new CPLPropertyEdit("indicator-x", LOC("/str1097/Indicator X"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorX);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pEdit = new CPLPropertyEdit("indicator-y", LOC("/str1098/Indicator Y"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorY);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pEdit = new CPLPropertyEdit("indicator-width", LOC("/str1099/Indicator Width"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorWidth);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pEdit = new CPLPropertyEdit("indicator-height", LOC("/str1100/Indicator Height"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", Doc->m_Settings->m_EdGame->m_IndicatorHeight);
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_SIGNED, false);

	pColor = new CPLPropertyColor("indicator-color", LOC("/str1101/Indicator Color"));
	pColor->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pColor);
	pColor->SetRGB(D3DCOLGetR(Doc->m_Settings->m_EdGame->m_IndicatorColor), D3DCOLGetG(Doc->m_Settings->m_EdGame->m_IndicatorColor), D3DCOLGetB(Doc->m_Settings->m_EdGame->m_IndicatorColor));


	pEdit = new CPLPropertyEdit("indicator-alpha", LOC("/str1102/Indicator Transparency"));
	pEdit->m_HelpFile = "indicator";
	m_PropList.AddProperty(cat, pEdit);
	val.Format("%d", D3DCOLGetA(Doc->m_Settings->m_EdGame->m_IndicatorColor));
	pEdit->SetValue(val);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 255);


	pEditEx = new CPLPropertyEditEx("save-load-image", LOC("/str1104/Save/load screen"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonSaveLoad, this);
	m_PropList.AddProperty(cat, pEditEx);

	if(Doc->m_Settings->m_EdGame->m_SaveImageName || Doc->m_Settings->m_EdGame->m_LoadImageName)
		str = LOC("/str1105/<set>");
	else
		str = LOC("/str1106/<not set>");
	pEditEx->SetValue(str);

	pEdit = new CPLPropertyEdit("save-ext", LOC("/str1158/File extension"));
	m_PropList.AddProperty(cat, pEdit);
	if(Doc->m_Settings->m_SavedGameExt) pEdit->SetValue(Doc->m_Settings->m_SavedGameExt);
	else pEdit->SetValue("");


	pCombo = new CPLPropertyCombo("rich-save", LOC("/str1157/Rich saved games"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_Settings->m_RichSavedGames?LOC("/str1000/Yes"):LOC("/str1001/No"));


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("debug", LOC("/str0036/Debugging settings"));

	pCombo = new CPLPropertyCombo("debug-mode", LOC("/str0037/Debug mode"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_DebugMode?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("show-fps", LOC("/str0038/Show FPS"));
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_ShowFPS?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("allow-windowed", LOC("/str0039/Allow windowed"));
	pCombo->m_HelpFile = "allow-windowed-d";
	pCombo->SetupBool();
	m_PropList.AddProperty(cat,  pCombo);
	pCombo->SetValue(Doc->m_AllowWindowed?LOC("/str1000/Yes"):LOC("/str1001/No"));

	pCombo = new CPLPropertyCombo("console-mode", LOC("/str1129/Debugging console"));
	pCombo->AddValue(LOC("/str1130/Never"), "0");
	pCombo->AddValue(LOC("/str1131/In windowed mode"), "1");
	pCombo->AddValue(LOC("/str1132/Always"), "2");
	m_PropList.AddProperty(cat,  pCombo);
	switch(Doc->m_ConsoleMode)
	{
		case 0:
			pCombo->SetValue("0");
			break;
		case 2:
			pCombo->SetValue("2");
			break;
		default:
			pCombo->SetValue("1");
	}	

	pEditEx = new CPLPropertyEditEx("startup-scene-d", LOC("/str1087/Startup scene"));
	pEditEx->m_ReadOnly = true;
	pEditEx->SetButtonPressCallback(HookButtonFile, this);
	m_PropList.AddProperty(cat, pEditEx);
	if(Doc->m_Settings->m_EdGame->m_DebugStartupScene)
		pEditEx->SetValue(Doc->m_Settings->m_EdGame->m_DebugStartupScene);


	//////////////////////////////////////////////////////////////////////////
	cat = m_PropList.AddCategory("package", LOC("/str0040/Selected package"));

	pEdit = new CPLPropertyEdit("description", LOC("/str0041/Description"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_ANY, true, 0, 100);

	/*
	pEdit = new CPLPropertyEdit("cd", LOC("/str0042/CD"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 99);
	*/

	pEdit = new CPLPropertyEdit("priority", LOC("/str0043/Priority"));
	m_PropList.AddProperty(cat, pEdit);
	pEdit->SetValidation(CPLPropertyEdit::EDIT_UNSIGNED, true, 0, 200);

	m_PropList.ShowCategory("package", false);

	return S_OK;
}
Exemplo n.º 14
0
HBITMAP FAR CJpegFile::CopyScreenToBitmap(LPRECT lpRect)
{
	HDC hScrDC, hMemDC;           // screen DC and memory DC
	HBITMAP hBitmap, hOldBitmap;  // handles to deice-dependent bitmaps
	int nX, nY, nX2, nY2;         // coordinates of rectangle to grab
	int nWidth, nHeight;          // DIB width and height
	int xScrn, yScrn;             // screen resolution
	
	/* check for an empty rectangle */
	
	if (IsRectEmpty(lpRect))
		return NULL;
	
	/*  create a DC for the screen and create
	 *  a memory DC compatible to screen DC
     */
	hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);
	hMemDC = CreateCompatibleDC(hScrDC);
	
	/* get points of rectangle to grab */
	nX = lpRect->left;
	nY = lpRect->top;
	nX2 = lpRect->right;
	nY2 = lpRect->bottom;
	
	/* get screen resolution */
	xScrn = GetDeviceCaps(hScrDC, HORZRES);
	yScrn = GetDeviceCaps(hScrDC, VERTRES);
	
	/* make sure bitmap rectangle is visible */
	if (nX < 0)
		nX = 0;
	if (nY < 0)
		nY = 0;
	if (nX2 > xScrn)
		nX2 = xScrn;
	if (nY2 > yScrn)
		nY2 = yScrn;
	nWidth = nX2 - nX;
	nHeight = nY2 - nY;
	
	/* create a bitmap compatible with the screen DC */
	hBitmap = CreateCompatibleBitmap(hScrDC, nWidth, nHeight);
	
	/* select new bitmap into memory DC */
	hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
	
	/* bitblt screen DC to memory DC */
	BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY);
	
	/*  select old bitmap back into memory DC and get handle to
	 *  bitmap of the screen
	 */
	hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap);
	
	/* clean up */
	DeleteDC(hScrDC);
	DeleteDC(hMemDC);
	
	/* return handle to the bitmap */
	return hBitmap;
}
Exemplo n.º 15
0
//*增加的函数
//考贝屏幕
HBITMAP CCatchScreenDlg::CopyScreenToBitmap(LPRECT lpRect, BOOL bSave)
//lpRect 代表选定区域
{
	HDC hScrDC, hMemDC;      
	// 屏幕和内存设备描述表
	HBITMAP    hBitmap, hOldBitmap;   
	// 位图句柄
	int       nX, nY, nX2, nY2;      
	// 选定区域坐标
	int       nWidth, nHeight;
	
	// 确保选定区域不为空矩形
	if (IsRectEmpty(lpRect))
		return NULL;
	//为屏幕创建设备描述表
	hScrDC = CreateDC("DISPLAY", NULL, NULL, NULL);

	//为屏幕设备描述表创建兼容的内存设备描述表
	hMemDC = CreateCompatibleDC(hScrDC);
	// 获得选定区域坐标
	nX = lpRect->left;
	nY = lpRect->top;
	nX2 = lpRect->right;
	nY2 = lpRect->bottom;

	//确保选定区域是可见的
	if (nX < 0)
		nX = 0;
	if (nY < 0)
		nY = 0;
	if (nX2 > m_nCXScreen)
		nX2 = m_nCXScreen;
	if (nY2 > m_nCYScreen)
		nY2 = m_nCYScreen;
	nWidth = nX2 - nX;
	nHeight = nY2 - nY;
	// 创建一个与屏幕设备描述表兼容的位图
	hBitmap = CreateCompatibleBitmap
		(hScrDC, nWidth, nHeight);
	
	// 把新位图选到内存设备描述表中
	hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
	// 把屏幕设备描述表拷贝到内存设备描述表中
	
	if(bSave)
	{
		CDC dcCompatible;
		dcCompatible.CreateCompatibleDC(CDC::FromHandle(hMemDC));
		dcCompatible.SelectObject(m_BackgroundBitmap);
        
		BitBlt(hMemDC, 0, 0, nWidth, nHeight,
			dcCompatible, nX, nY, SRCCOPY);
	}
	else
	{
		BitBlt(hMemDC, 0, 0, nWidth, nHeight,
			hScrDC, nX, nY, SRCCOPY);
	}

	hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap);
	//得到屏幕位图的句柄
	//清除 
	DeleteDC(hScrDC);
	DeleteDC(hMemDC);
	// 返回位图句柄
	if(bSave)
	{
		if (OpenClipboard()) 
		{
			//清空剪贴板
			EmptyClipboard();
			//把屏幕内容粘贴到剪贴板上,
			//hBitmap 为刚才的屏幕位图句柄
			SetClipboardData(CF_BITMAP, hBitmap);
			//关闭剪贴板
			CloseClipboard();
		}
	}
	return hBitmap;
}
Exemplo n.º 16
0
BOOL wf_info_have_invalid_region(wfInfo* wfi)
{
	return IsRectEmpty(&wfi->invalid);
}
Exemplo n.º 17
0
bool WCreateEditWindow( HINSTANCE inst, WStringEditInfo *einfo )
{
    int         x, y, width, height;
    char        *title;
    HMENU       hmenu;
    HMENU       menu;
    bool        is_rc;
    RECT        rect;

    if( einfo == NULL ) {
        return( FALSE );
    }

    x = CW_USEDEFAULT;
    y = CW_USEDEFAULT;
    width = appWidth;
    height = appHeight;

    if( einfo->info->stand_alone ) {
        WGetScreenPosOption( &rect );
        if( !IsRectEmpty( &rect ) ) {
            x = rect.left;
            y = rect.top;
            width = appWidth;
            if( width < rect.right - rect.left )
                width = rect.right - rect.left;
            height = appHeight;
            if( height < rect.bottom - rect.top ) {
                height = rect.bottom - rect.top;
            }
        }
    }

    is_rc = FALSE;
    title = WCreateEditTitle( einfo );
    if( title == NULL ) {
        title = AllocRCString( W_STRINGAPPTITLE );
        is_rc = TRUE;
    }

    menu = (HMENU)NULL;
    if( einfo->info->stand_alone ) {
        menu = LoadMenu( inst, WMainSOMenuName );
    }

    einfo->win = CreateWindow( WMainClass, title, WS_OVERLAPPEDWINDOW,
                               x, y, width, height, einfo->info->parent,
                               menu, inst, einfo );

    if( title != NULL ) {
        if( is_rc ) {
            FreeRCString( title );
        } else {
            WRMemFree( title );
        }
    }

    if( einfo->win == (HWND)NULL ) {
        return( FALSE );
    }

    if( !WCreateRibbon( einfo ) ) {
        return( FALSE );
    }

    einfo->wsb = WCreateStatusLine( einfo->win, inst );
    if( einfo->wsb == NULL ) {
        return( FALSE );
    }

    if( !WCreateStringEditWindow( einfo, inst ) ) {
        return( FALSE );
    }

    hmenu = GetMenu( einfo->win );
    if( hmenu != (HMENU)NULL ) {
        EnableMenuItem( hmenu, IDM_STR_CUT, MF_GRAYED );
        EnableMenuItem( hmenu, IDM_STR_COPY, MF_GRAYED );
    }

    if( WGetOption( WOptScreenMax ) ) {
        ShowWindow( einfo->win, SW_SHOWMAXIMIZED );
    } else {
        ShowWindow( einfo->win, SW_SHOWNORMAL );
    }
    UpdateWindow( einfo->win );

    WResizeWindows( einfo );

    SetFocus( einfo->edit_dlg );

    return( TRUE );
}
Exemplo n.º 18
0
bool 
SeqParamSet::Parse(NALUnit* pnalu)
{
    if (pnalu->Type() != NALUnit::NAL_Sequence_Params)
    {
        return false;
    }

    // with the UE/SE type encoding, we must decode all the values
    // to get through to the ones we want
    pnalu->ResetBitstream();
    pnalu->Skip(8);     // type
    m_Profile = pnalu->GetWord(8);
    m_Compatibility = (BYTE) pnalu->GetWord(8);
    m_Level = pnalu->GetWord(8);

    /*int seq_param_id =*/ pnalu->GetUE();

    if ((m_Profile == 100) || (m_Profile == 110) || (m_Profile == 122) || (m_Profile == 144))
    {
        int chroma_fmt = pnalu->GetUE();
        if (chroma_fmt == 3)
        {
            pnalu->Skip(1);
        }
        /* int bit_depth_luma_minus8 = */ pnalu->GetUE();
        /* int bit_depth_chroma_minus8 = */ pnalu->GetUE();
        pnalu->Skip(1);
        int seq_scaling_matrix_present = pnalu->GetBit();
        if (seq_scaling_matrix_present)
        {
            for (int i = 0; i < 8; i++)
            {
                if (pnalu->GetBit())
                {
                    if (i < 6)
                    {
                        ScalingList(16, pnalu);
                    }
                    else
                    {
                        ScalingList(64, pnalu);
                    }
                }
            }
        }
    }

    int log2_frame_minus4 = pnalu->GetUE();
    m_FrameBits = log2_frame_minus4 + 4;
    int POCtype = pnalu->GetUE();
    if (POCtype == 0)
    {
        /*int log2_poc_minus4 =*/ pnalu->GetUE();
    } else if (POCtype == 1) 
    {
        pnalu->Skip(1); // delta always zero
        /*int nsp_offset =*/ pnalu->GetSE();
        /*int nsp_top_to_bottom = */ pnalu->GetSE();
        int num_ref_in_cycle = pnalu->GetUE();
        for (int i = 0; i < num_ref_in_cycle; i++)
        {
            /*int sf_offset =*/ pnalu->GetSE();
        }
    } 
    else if (POCtype != 2)
    {
        return false;
    }
    // else for POCtype == 2, no additional data in stream
    
    /*int num_ref_frames =*/ pnalu->GetUE();
    /*int gaps_allowed =*/ pnalu->GetBit();

    int mbs_width = pnalu->GetUE();
    int mbs_height = pnalu->GetUE();
    m_cx = (mbs_width+1) * 16;
    m_cy = (mbs_height+1) * 16;

    // smoke test validation of sps
    if ((m_cx > 2000) || (m_cy > 2000))
    {
        return false;
    }

    // if this is false, then sizes are field sizes and need adjusting
    m_bFrameOnly = pnalu->GetBit() ? true : false;
    
    if (!m_bFrameOnly)
    {
        pnalu->Skip(1); // adaptive frame/field
    }
    pnalu->Skip(1);     // direct 8x8

    SetRect(&m_rcFrame, 0, 0, 0, 0);
    bool bCrop = pnalu->GetBit() ? true : false;
    if (bCrop) {
        // get cropping rect 
        // store as exclusive, pixel parameters relative to frame
        m_rcFrame.left = pnalu->GetUE() * 2;
        m_rcFrame.right = pnalu->GetUE() * 2;
        m_rcFrame.top = pnalu->GetUE() * 2;
        m_rcFrame.bottom = pnalu->GetUE() * 2;
    }

    if (!IsRectEmpty(&m_rcFrame))
    {
        m_rcFrame.right = m_cx - m_rcFrame.right;
        m_rcFrame.bottom = m_cy - m_rcFrame.bottom;
    }

    // adjust rect from 2x2 units to pixels

    if (!m_bFrameOnly)
    {
        // adjust heights from field to frame
        m_cy *= 2;
        m_rcFrame.top *= 2;
        m_rcFrame.bottom *= 2;
    }

    // .. rest are not interesting yet
    return true;
}
Exemplo n.º 19
0
void CSelection::SetSelectionFromPoint( CEditView *pView, int x, int y, BOOL bEmpty, BOOL bAllowLineSel )
{
	ASSERT( bEmpty || ( pView == m_pView ) );

	if ( m_pView != pView )
	{
		CEditView *pLastView = m_pView;
		m_pView = pView;
		if ( !IsEmpty() )
		{
			// switching views -- erase the selection in the other view
			pLastView->DamageView( min( m_nEndRow, m_nStartRow ), max( m_nEndRow, m_nStartRow ) );
		}
	}

	int nCol, nRow;
	RECT rcChar;
	m_pView->GetCharPosFromPoint( x, y, nCol, nRow, &rcChar );

	RECT rcView;
	m_pView->GetViewRect( &rcView );
	CBuffer *pBuffer = m_pCtrl->GetBuffer();
	int nLineCount = pBuffer->GetLineCount();

	if ( !bEmpty && bAllowLineSel && ( x > rcView.left && x < ( rcView.left + m_pView->GetLeftMargin( TRUE ) ) ) )
	{
		// line selecting
		nCol = 0;
		if ( nRow < m_nStartRow )
		{
			m_nStartCol = CEditView::MAXCOL;
		}
		else
		{
			m_nStartCol = 0;
			nRow++;
		}
		nRow = min( nRow, nLineCount - 1 );
		nRow = max( 0, nRow );
		// selecting the last line should just go to the end of the line since
		// there is no line below nRow.
		if ( nLineCount && ( nRow == nLineCount - 1 ) )
		{
			nCol = pBuffer->GetLineLength( nRow );
		}
	}
	else
	{
		nRow = min( nRow, nLineCount - 1 );
		nRow = max( 0, nRow );
		nCol = pBuffer->ConvertViewColToBufferCol( nRow, nCol );
	}

	// since the column might have changed above, let's refetch the
	// char rect.
	m_pView->GetCharBoundingRect( nCol, nRow, &rcChar );

	if ( !IsRectEmpty( &rcChar ) && ( x > ( ( rcChar.left + rcChar.right ) / 2 ) ) )
	{
		// cursor is closer to the next char
		nCol += pBuffer->GetCharSize( nRow, nCol );
	}

	if ( bEmpty )
	{
		SetEmptySelection( nCol, nRow );
	}
	else
	{
		if ( nCol != m_nEndCol || nRow != m_nEndRow )
			ExtendTo( nCol, nRow );
	}
}
Exemplo n.º 20
0
LOCAL void Story_OnDraw(HWND hWindow, HDC hDC, LPRECT lpRect, BOOL fHighlight)
/***********************************************************************/
{
	BOOL bHasFocus, bSelected, bDown;
	DWORD dwStyle;
	RECT rSrcArea, rDstArea;
	POINT ptDst;
	PDIB pdibSrc, pdibDst, pDib;
	LPOFFSCREEN lpOffScreen;
	PTOON pToon;
	LPSCENE lpScene;
	PSTORY pStory;
	RGBQUAD rgbQuad[256];
	BITMAPINFOHEADER bmi;
	LPTR lp;
	HDC hWinGDC;
	HPALETTE hWinGPal = NULL, hDisplayPal = NULL, hOldPal;

	if (IsRectEmpty(lpRect))
		return;
	pStory = GetStory(hWindow);
	if (!pStory)
		return;
	if (!pStory->m_pDib)
		return;
	lpScene = CScene::GetScene(GetParent(hWindow));
	if (!lpScene)
		return;

	rSrcArea = *lpRect;
	rDstArea = *lpRect;
	bSelected = GetWindowWord(hWindow, GWW_STATE );
	dwStyle = GetWindowLong( hWindow, GWL_STYLE );
	bHasFocus = ( GetFocus() == hWindow );
	bDown = ( bSelected || (bTrack && bInRect && bHasFocus) );

	lpOffScreen = lpScene->GetOffScreen();
	if (lpOffScreen)
	{
		MapWindowPoints( hWindow, GetParent(hWindow), (LPPOINT)&rDstArea, 2 );
 		if ( !(pdibSrc = lpOffScreen->GetReadOnlyDIB()) )
			return;
		if ( !(pdibDst = lpOffScreen->GetWritableDIB()) )
			return;
		hWinGDC = lpOffScreen->GetDC();
		hWinGPal = hDisplayPal = GetApp()->m_hPal;
	}
	else
	{
		// fix
		HWND hToon = FindClassDescendent(GetParent(hWindow), "toon");
		if (!hToon)
			return;
		pToon = GetToon(hToon);
		if (!pToon)
			return;
		MapWindowPoints( hWindow, pToon->GetWindow(), (LPPOINT)&rDstArea, 2 );
		pdibSrc = pToon->GetStageDib();
		lp = ToonGetDIBPointer(pToon->GetToonHandle(), &bmi);
		ToonGetColors(pToon->GetToonHandle(), 0, 256, rgbQuad);
		bmi.biClrUsed = 256;
		pdibDst = new CDib(&bmi, rgbQuad, lp);
		if (!pdibDst)
			return;
		hWinGDC = ToonDC(pToon->GetToonHandle());
		// to make sure we don't change the system palette
		hDisplayPal = CopySystemPalette();
		// to match WinG dib
		hWinGPal = CreateCustomPalette(rgbQuad, 256);
	}

	if (!pStory->m_fMappedToPalette && ((dwStyle & BS_MASK) == 0))
	{
		pStory->m_pDib->MapToPalette(hWinGPal);
		pStory->m_fMappedToPalette = TRUE;
	}


	// Copy source dib so we can twiddle its bits
	pDib = new CDib();
	if (!pDib)
	{
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	if (!pDib->Create(pStory->m_pDib->GetBitCount(),
						lpRect->right-lpRect->left,
						lpRect->bottom-lpRect->top))
	{
		delete pDib;
		if (!lpOffScreen && hDisplayPal)
			DeleteObject(hDisplayPal);
		if (!lpOffScreen && hWinGPal)
			DeleteObject(hWinGPal);
		return;
	}
	pDib->CopyColorTable(pStory->m_pDib);
	// draw in source bitmap
	pStory->m_pDib->DibBlt( pDib,
					0, 0,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	rSrcArea.left, rSrcArea.top,
				 	rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
				 	NO /*bTransparent*/ );
	
	if ( pdibSrc->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8)
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pdibSrc->DCBlt( hWinGDC,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
	}
	else
	{
		pdibSrc->DibBlt( pdibDst,
						rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	rDstArea.left, rDstArea.top,
					 	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					 	NO /*bTransparent*/ );
	}

	if ( pDib->GetCompression() == BI_RLE8 ||
		 pdibDst->GetCompression() == BI_RLE8 )
	{ // compressed DIBs must use GDI copying (lose transparency ability)
		pDib->DCBlt( hWinGDC,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					rSrcArea.left, rSrcArea.top,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top );
	}
	else
	{
		RGBTRIPLE rgb;
		LPRGBTRIPLE lpRGB = NULL;
		if (dwStyle & BS_MASK)
		{
			STRING szColor;
			GetWindowText(hWindow, szColor, sizeof(szColor));
			AsciiRGB( szColor, &rgb );
			if (fHighlight)
			{
				// this relies on the fact that AsciiRGB replaces commas
				// with NULL terminators
				LPTSTR lp = szColor + lstrlen(szColor) + 1; // passed red
				lp += lstrlen(lp) + 1; // passed green
				lp += lstrlen(lp) + 1; // passed blue to higlight color
				AsciiRGB(lp, &rgb);
				rgb.rgbtRed = rgb.rgbtGreen = 0; rgb.rgbtBlue = 255;
			}
			else
				rgb.rgbtRed = rgb.rgbtGreen = rgb.rgbtBlue = 0;
			lpRGB = &rgb;
		}
		else
		{
			BYTE bTrans = *pStory->m_pDib->GetXY(0, 0);
			LPTR lpColor = pStory->m_pDib->GetXY(1, 0);
			LPTR lpHighlight = pStory->m_pDib->GetXY(2, 0); 
			BYTE bColor = *lpColor;
			BYTE bHighlight = *lpHighlight;
			// if highlight color is the transparent color then
			// we are hiding and showing highlighted area
			// if not, then we are changing the color of highlighted area
			if (bHighlight == bTrans)
			{
				// we need to strip off highlight info if we are not
				// highlighted
				if (!fHighlight && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp != bColor)
							*hp = bTrans;
						++hp;
						--dwSize;
					}
				}
			}
			else
			{
				// we need to change the color if we are highlighted
				if (fHighlight && (bColor != bHighlight) && (bColor != bTrans))
				{
					HPTR hp = pDib->GetPtr();
					DWORD dwSize = pDib->GetSizeImage();
					while (dwSize)
					{
						if (*hp == bColor)
							*hp = bHighlight;
						++hp;
						--dwSize;
					}
				}
			}
		}
		pDib->DibBlt( pdibDst,
					rDstArea.left, rDstArea.top,
					rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
					0, 0,
					rSrcArea.right - rSrcArea.left, rSrcArea.bottom - rSrcArea.top,
					YES/*bTransparent*/, lpRGB, NULL, hWinGPal );
	}
	delete pDib;

	ptDst.x = rSrcArea.left;
	ptDst.y = rSrcArea.top;
	if (lpOffScreen)
	{
		lpOffScreen->DrawRect( hDC, &rDstArea, &ptDst );
	}
	else
	{
		//if (hDisplayPal)
		//{
		//	hOldPal = SelectPalette(hDC, hDisplayPal, FALSE);
		//	RealizePalette(hDC);
		//}
		//pdibDst->DCBlt( hDC,
		//	ptDst.x, ptDst.y,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
		//	rDstArea.left, rDstArea.top,
		//	rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		WinGStretchBlt( hDC,
			ptDst.x, ptDst.y,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top,
			hWinGDC,
			rDstArea.left, rDstArea.top,
			rDstArea.right - rDstArea.left, rDstArea.bottom - rDstArea.top );
		//if (hDisplayPal)
	    //{
		//	SelectPalette(hDC, hOldPal, TRUE);
	   	//	DeleteObject(hDisplayPal);
		//}
		if (hWinGPal)
			DeleteObject(hWinGPal);
	}
}
Exemplo n.º 21
0
// Create an instance of the Mozilla embeddable browser
//
HRESULT CBrowserView::CreateBrowser()
{
    // Create web shell
    nsresult rv;
    mWebBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
    if(NS_FAILED(rv))
        return rv;

    // Save off the nsIWebNavigation interface pointer
    // in the mWebNav member variable which we'll use
    // later for web page navigation
    //
    rv = NS_OK;
    mWebNav = do_QueryInterface(mWebBrowser, &rv);
    if(NS_FAILED(rv))
        return rv;

//	mSessionHistory = do_GetInterface(mWebBrowser, &rv); // de: added 5/11

    // Create the CBrowserImpl object - this is the object
    // which implements the interfaces which are required
    // by an app embedding mozilla i.e. these are the interfaces
    // thru' which the *embedded* browser communicates with the
    // *embedding* app
    //
    // The CBrowserImpl object will be passed in to the
    // SetContainerWindow() call below
    //
    // Also note that we're passing the BrowserFrameGlue pointer
    // and also the mWebBrowser interface pointer via CBrowserImpl::Init()
    // of CBrowserImpl object.
    // These pointers will be saved by the CBrowserImpl object.
    // The CBrowserImpl object uses the BrowserFrameGlue pointer to
    // call the methods on that interface to update the status/progress bars
    // etc.
    mpBrowserImpl = new CBrowserImpl();
    if(mpBrowserImpl == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;

    // Pass along the mpBrowserFrameGlue pointer to the BrowserImpl object
    // This is the interface thru' which the XP BrowserImpl code communicates
    // with the platform specific code to update status bars etc.
    mpBrowserImpl->Init(mpBrowserFrameGlue, mWebBrowser);
    mpBrowserImpl->AddRef();

    mWebBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome*>(mpBrowserImpl));

    rv = NS_OK;
    nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(mWebBrowser, &rv);
    if(NS_FAILED(rv))
        return rv;
    dsti->SetItemType(nsIDocShellTreeItem::typeContentWrapper);

    // Create the real webbrowser window

    // Note that we're passing the m_hWnd in the call below to InitWindow()
    // (CBrowserView inherits the m_hWnd from CWnd)
    // This m_hWnd will be used as the parent window by the embeddable browser
    //
    rv = NS_OK;
    mBaseWindow = do_QueryInterface(mWebBrowser, &rv);
    if(NS_FAILED(rv))
        return rv;

    // Get the view's ClientRect which to be passed in to the InitWindow()
    // call below
    RECT rcLocation;
    GetClientRect(&rcLocation);
    if(IsRectEmpty(&rcLocation))
    {
        rcLocation.bottom++;
        rcLocation.top++;
    }

    rv = mBaseWindow->InitWindow(nsNativeWidget(m_hWnd), nsnull,
                                 0, 0, rcLocation.right - rcLocation.left, rcLocation.bottom - rcLocation.top);
    rv = mBaseWindow->Create();

    // Register the BrowserImpl object to receive progress messages
    // These callbacks will be used to update the status/progress bars

    /*		// from WinEmbed.cpp
    	nsCOMPtr<nsIWebProgressListener> listener(static_cast<nsIWebProgressListener*>(this));
        nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener));
        (void)mWebBrowser->AddWebBrowserListener(thisListener,
           NS_GET_IID(nsIWebProgressListener));

        // The window has been created. Now register for history notifications
        rv = mWebBrowser->AddWebBrowserListener(thisListener, NS_GET_IID(nsISHistoryListener));
    */

    // Finally, show the web browser window
    mBaseWindow->SetVisibility(PR_TRUE);

    qaTests = new CTests(mWebBrowser, mBaseWindow, mWebNav, mpBrowserImpl);
    //nsiRequest = new CNsIRequest(mWebBrowser,mpBrowserImpl);
    return S_OK;
}
Exemplo n.º 22
0
/* on WM_PAINT */
void onPaint(HWND hWnd) 
{
	PNHMapWindow data;
	PAINTSTRUCT ps;
	HDC hDC;
	HDC tileDC;
	HGDIOBJ saveBmp;
	RECT paint_rt;
	int i, j;

	/* get window data */
	data = (PNHMapWindow)GetWindowLong(hWnd, GWL_USERDATA);

	hDC = BeginPaint(hWnd, &ps);

	/* calculate paint rectangle */
	if( !IsRectEmpty(&ps.rcPaint) ) {
		/* calculate paint rectangle */
		paint_rt.left = max(data->xPos + (ps.rcPaint.left - data->map_orig.x)/data->xScrTile, 0);
		paint_rt.top = max(data->yPos + (ps.rcPaint.top - data->map_orig.y)/data->yScrTile, 0);
		paint_rt.right = min(data->xPos + (ps.rcPaint.right - data->map_orig.x)/data->xScrTile+1, COLNO);
		paint_rt.bottom = min(data->yPos + (ps.rcPaint.bottom - data->map_orig.y)/data->yScrTile+1, ROWNO);

		if( data->bAsciiMode
#ifdef REINCARNATION
		    || Is_rogue_level(&u.uz) 
			/* You enter a VERY primitive world! */
#endif
			) {
			HGDIOBJ oldFont;

			oldFont = SelectObject(hDC, data->hMapFont);
			SetBkMode(hDC, TRANSPARENT);

			/* draw the map */
			for(i=paint_rt.left; i<paint_rt.right; i++) 
			for(j=paint_rt.top; j<paint_rt.bottom; j++) 
			if(data->map[i][j]>=0) {
				char ch;
				TCHAR wch;
				RECT  glyph_rect;
				int   color;
				unsigned special;
				int mgch;
				HBRUSH back_brush;
				COLORREF OldFg;

				nhcoord2display(data, i, j, &glyph_rect);

#if (VERSION_MAJOR < 4) && (VERSION_MINOR < 4) && (PATCHLEVEL < 2)
				nhglyph2charcolor(data->map[i][j], &ch, &color);
				OldFg = SetTextColor (hDC, nhcolor_to_RGB(color) );
#else
				/* rely on NetHack core helper routine */
				mapglyph(data->map[i][j], &mgch, &color,
						&special, i, j);
				ch = (char)mgch;
				if (((special & MG_PET) && iflags.hilite_pet) ||
				    ((special & MG_DETECT) && iflags.use_inverse)) {
					back_brush = CreateSolidBrush(nhcolor_to_RGB(CLR_GRAY));
					FillRect (hDC, &glyph_rect, back_brush);
					DeleteObject (back_brush);
					switch (color)
					{
					case CLR_GRAY:
					case CLR_WHITE:
						OldFg = SetTextColor( hDC,  nhcolor_to_RGB(CLR_BLACK));
						break;
					default:
						OldFg = SetTextColor (hDC, nhcolor_to_RGB(color) );
					}
				} else {
					OldFg = SetTextColor (hDC, nhcolor_to_RGB(color) );
				}
#endif

				DrawText(hDC, 
						 NH_A2W(&ch, &wch, 1),
						 1,
						 &glyph_rect,
						 DT_CENTER | DT_VCENTER | DT_NOPREFIX
						 );
				SetTextColor (hDC, OldFg);
			}
			SelectObject(hDC, oldFont);
		} else {
			/* prepare tiles DC for mapping */
			tileDC = CreateCompatibleDC(hDC);
			saveBmp = SelectObject(tileDC, GetNHApp()->bmpMapTiles);

			/* draw the map */
			for(i=paint_rt.left; i<paint_rt.right; i++) 
			for(j=paint_rt.top; j<paint_rt.bottom; j++) 
				if(data->map[i][j]>=0) {
					short ntile;
					int t_x, t_y;
					RECT glyph_rect;

					ntile = glyph2tile[ data->map[i][j] ];
					t_x = (ntile % GetNHApp()->mapTilesPerLine)*GetNHApp()->mapTile_X;
					t_y = (ntile / GetNHApp()->mapTilesPerLine)*GetNHApp()->mapTile_Y;
					
					nhcoord2display(data, i, j, &glyph_rect);

					StretchBlt( 
						hDC, 
						glyph_rect.left,
						glyph_rect.top, 
						data->xScrTile,
						data->yScrTile,
						tileDC,
						t_x,
						t_y,
						GetNHApp()->mapTile_X, 
						GetNHApp()->mapTile_Y, 
						SRCCOPY 
					);
					if( glyph_is_pet(data->map[i][j]) && iflags.wc_hilite_pet ) {
						/* apply pet mark transparently over 
						   pet image */
						HDC hdcPetMark;
						HBITMAP    bmPetMarkOld;

						/* this is DC for petmark bitmap */
						hdcPetMark = CreateCompatibleDC(hDC);
						bmPetMarkOld = SelectObject(hdcPetMark, GetNHApp()->bmpPetMark);

						nhapply_image_transparent( 
							hDC,
							glyph_rect.left,
							glyph_rect.top, 
							data->xScrTile,
							data->yScrTile,
							hdcPetMark,
							0,
							0,
							TILE_X, 
							TILE_Y,
							TILE_BK_COLOR 
						);
						SelectObject(hdcPetMark, bmPetMarkOld);
						DeleteDC(hdcPetMark);
					}
				}
			SelectObject(tileDC, saveBmp);
			DeleteDC(tileDC);
		}

		/* draw focus rect */
		nhcoord2display(data, data->xCur, data->yCur, &paint_rt);
		if( data->bAsciiMode ) {
			PatBlt( hDC, 
				    paint_rt.left, paint_rt.top, 
				    paint_rt.right-paint_rt.left, paint_rt.bottom-paint_rt.top, 
				    DSTINVERT );	
		} else {
			DrawFocusRect(hDC, &paint_rt);
		}
	}
	EndPaint(hWnd, &ps);
}
Exemplo n.º 23
0
void
IntDrawScrollBar(HWND Wnd, HDC DC, INT Bar)
{
  //PSBWND pSBWnd;
  //INT ThumbSize;
  SCROLLBARINFO Info;
  BOOL Vertical;

  /*
   * Get scroll bar info.
   */
  switch (Bar)
    {
      case SB_HORZ:
        Vertical = FALSE;
        break;

      case SB_VERT:
        Vertical = TRUE;
        break;

      case SB_CTL:
        Vertical = (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_VERT) != 0;
        break;

      default:
        return;
    }
  if (!IntGetScrollBarInfo(Wnd, Bar, &Info))
  {
      return;
  }

  if (IsRectEmpty(&Info.rcScrollBar))
  {
      return;
  }

  //ThumbSize = pSBWnd->pSBCalc->pxThumbBottom - pSBWnd->pSBCalc->pxThumbTop;

  /*
   * Draw the arrows.
   */
  if (Info.dxyLineButton)
  {
      IntDrawScrollArrows(DC, &Info, Vertical);
  }

  /*
   * Draw the interior.
   */
  IntDrawScrollInterior(Wnd, DC, Bar, Vertical, &Info);

  /*
   * If scroll bar has focus, reposition the caret.
   */
  if (Wnd == GetFocus() && SB_CTL == Bar)
  {
      if (Vertical)
      {
          SetCaretPos(Info.rcScrollBar.top + 1, Info.dxyLineButton + 1);
      }
      else
      {
           SetCaretPos(Info.dxyLineButton + 1, Info.rcScrollBar.top + 1);
      }
  }
}