本文整理汇总了C++中SetViewportOrgEx函数的典型用法代码示例。如果您正苦于以下问题:C++ SetViewportOrgEx函数的具体用法?C++ SetViewportOrgEx怎么用?C++ SetViewportOrgEx使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetViewportOrgEx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SCALEXf
void ShadowSur::EllipseSkew(const float centerx, const float centery, const float radius, const float z1, const float z2) const
{
const int basepixel = SCALEXf(m_z);
const int top = SCALEXf(z2) - basepixel;
if (top <= 0)
return; //This entire polygon is underneath this shadow level
int bottom = SCALEXf(z1) - basepixel;
if (bottom < 0)
bottom = 0; // Polygon crosses shadow level
const int ix = SCALEXf(centerx);
const int iy = SCALEYf(centery);
const int ir = SCALEDf(radius);
SelectObject(m_hdc, GetStockObject(BLACK_PEN));
SelectObject(m_hdc, GetStockObject(BLACK_BRUSH));
for (int i=bottom;i<top;i++)
{
//SetViewportOrgEx(m_hdc, i, -i, NULL);
SetViewportOrgEx(m_hdc, (int)((float)i*m_shadowDirX), (int)((float)i*m_shadowDirY), NULL);
::Ellipse(m_hdc, ix - ir, iy - ir, ix + ir, iy + ir);
}
SetViewportOrgEx(m_hdc, 0, 0, NULL);
}
示例2: DrawTime
void DrawTime(HWND hwnd, HBRUSH hBrushRed) {
PAINTSTRUCT ps;
HDC hdc;
hdc = BeginPaint(hwnd, &ps);
SetMapMode(hdc, MM_ISOTROPIC);
SetWindowExtEx(hdc, WINDOW_WIDTH, WINDOW_HEIGHT, NULL);
SetViewportExtEx(hdc, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, NULL);
SelectObject(hdc, GetStockObject(NULL_PEN));
SelectObject(hdc, hBrushRed);
SetBkMode(hdc, TRANSPARENT);
if (n_chess % 2 + 1 == 1) {
SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL);
_DisplayTime(hwnd, hdc);
SetViewportOrgEx(hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL);
DisplayTwoDigits(hdc, 0, FALSE);
DisplayColon(hdc);
DisplayTwoDigits(hdc, 0, FALSE);
} else {
SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL);
DisplayTwoDigits(hdc, 0, FALSE);
DisplayColon(hdc) ;
DisplayTwoDigits(hdc, 0, FALSE);
SetViewportOrgEx (hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL);
_DisplayTime(hwnd, hdc);
}
EndPaint(hwnd,&ps);
}
示例3: graphdefaults
void graphdefaults()
{
set_defaults();
for (int i = 0; i <= MAXCOLORS; i++) {
current_palette.colors[i] = i;
BGIpalette[i] = BGIcolor[i];
}
SetPaletteEntries(hPalette, BG, MAXCOLORS+1, BGIpalette);
RealizePalette(hdc[0]);
SetTextColor(hdc[0], PALETTEINDEX(text_color+BG));
SetTextColor(hdc[1], PALETTEINDEX(text_color+BG));
SetBkColor(hdc[0], PALETTEINDEX(BG));
SetBkColor(hdc[1], PALETTEINDEX(BG));
SelectClipRgn(hdc[0], NULL);
SelectClipRgn(hdc[1], NULL);
SetViewportOrgEx(hdc[0], 0, 0, NULL);
SetViewportOrgEx(hdc[1], 0, 0, NULL);
SelectObject(hdc[0], hBrush[fill_settings.pattern]);
SelectObject(hdc[1], hBrush[fill_settings.pattern]);
moveto(0,0);
}
示例4: while
void CLCDCollection::OnDraw(CLCDGfxBase &rGfx)
{
if(!IsVisible())
{
return;
}
//iterate through your objects and draw them
LCD_OBJECT_LIST::iterator it = m_Objects.begin();
while(it != m_Objects.end())
{
CLCDBase *pObject = *it++;
LCDUIASSERT(NULL != pObject);
if (pObject->IsVisible())
{
pObject->OnPrepareDraw(rGfx);
// create the clip region
HRGN hRgn = CreateRectRgn(pObject->GetOrigin().x, pObject->GetOrigin().y,
pObject->GetOrigin().x + pObject->GetWidth(),
pObject->GetOrigin().y + pObject->GetHeight());
// ensure that controls only draw within their specified region
SelectClipRgn(rGfx.GetHDC(), hRgn);
// free the region (a copy is used in the call above)
DeleteObject(hRgn);
// offset the control at its origin so controls use (0,0)
POINT ptPrevViewportOrg = { 0, 0 };
SetViewportOrgEx(rGfx.GetHDC(),
pObject->GetOrigin().x,
pObject->GetOrigin().y,
&ptPrevViewportOrg);
// allow controls to supply additional translation
// this allows controls to move freely within the confined viewport
OffsetViewportOrgEx(rGfx.GetHDC(),
pObject->GetLogicalOrigin().x,
pObject->GetLogicalOrigin().y,
NULL);
pObject->OnDraw(rGfx);
// set the clipping region to nothing
SelectClipRgn(rGfx.GetHDC(), NULL);
// restore the viewport origin
SetViewportOrgEx(rGfx.GetHDC(),
ptPrevViewportOrg.x,
ptPrevViewportOrg.y,
NULL);
// restore the viewport origin offset
OffsetViewportOrgEx(rGfx.GetHDC(), 0, 0, NULL);
}
}
}
示例5: METAFILE_PlaybackGetDC
static GpStatus METAFILE_PlaybackGetDC(GpMetafile *metafile)
{
GpStatus stat = Ok;
stat = GdipGetDC(metafile->playback_graphics, &metafile->playback_dc);
if (stat == Ok)
{
/* The result of GdipGetDC always expects device co-ordinates, but the
* device co-ordinates of the source metafile do not correspond to
* device co-ordinates of the destination. Therefore, we set up the DC
* so that the metafile's bounds map to the destination points where we
* are drawing this metafile. */
SetMapMode(metafile->playback_dc, MM_ANISOTROPIC);
SetWindowOrgEx(metafile->playback_dc, metafile->bounds.X, metafile->bounds.Y, NULL);
SetWindowExtEx(metafile->playback_dc, metafile->bounds.Width, metafile->bounds.Height, NULL);
SetViewportOrgEx(metafile->playback_dc, metafile->playback_points[0].X, metafile->playback_points[0].Y, NULL);
SetViewportExtEx(metafile->playback_dc,
metafile->playback_points[1].X - metafile->playback_points[0].X,
metafile->playback_points[2].Y - metafile->playback_points[0].Y, NULL);
}
return stat;
}
示例6: SetViewportOrgEx16
/***********************************************************************
* SetViewportOrgEx (GDI.480)
*/
BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt )
{
POINT pt32;
BOOL16 ret = SetViewportOrgEx( hdc, x, y, &pt32 );
if (pt) CONV_POINT32TO16( &pt32, pt );
return ret;
}
示例7: PageGDICalls
void PageGDICalls (HDC hdcPrn, int cxPage, int cyPage)
{
static TCHAR szTextStr[] = TEXT ("Hello, Printer!") ;
Rectangle (hdcPrn, 0, 0, cxPage, cyPage) ;
MoveToEx (hdcPrn, 0, 0, NULL) ;
LineTo (hdcPrn, cxPage, cyPage) ;
MoveToEx (hdcPrn, cxPage, 0, NULL) ;
LineTo (hdcPrn, 0, cyPage) ;
SaveDC (hdcPrn) ;
SetMapMode (hdcPrn, MM_ISOTROPIC) ;
SetWindowExtEx (hdcPrn, 1000, 1000, NULL) ;
SetViewportExtEx (hdcPrn, cxPage / 2, -cyPage / 2, NULL) ;
SetViewportOrgEx (hdcPrn, cxPage / 2, cyPage / 2, NULL) ;
Ellipse (hdcPrn, -500, 500, 500, -500) ;
SetTextAlign (hdcPrn, TA_BASELINE | TA_CENTER) ;
TextOut (hdcPrn, 0, 0, szTextStr, lstrlen (szTextStr)) ;
RestoreDC (hdcPrn, -1) ;
}
示例8: SetViewportOrgEx
void Fl_Gdi::place(double x, double y, double w, double h, double tx, double ty, double tw, double th,int align)
{
double dx, dy;
double s = tw/w;
if(s<(th/h)) {
dx = 0;
dy = (th - s * h)*iy/144;
} else {
s=th/h;
dy =0;
dx = (tw - s * w)*ix/144;
}
if(align & 3)
if(align & FL_ALIGN_TOP)
dy=0;
else
dy *=2;
if(align & 12)
if(align & FL_ALIGN_LEFT)
dx=0;
else
dx *=2;
SetViewportOrgEx(gc_, VOx = (int)(ix * (lm_+tx) /72 - ox + dx), VOy = (int)( iy *(tm_+th) /72 - oy + dy),0); //setting origin to the upper left corner inside margins
SetWindowOrgEx(gc_, WOx = (int)x, WOy = (int)y,0);
SetViewportExtEx(gc_, VEx =(int)(ix*s), VEy =(int)(iy*s), 0);
SetWindowExtEx(gc_, WEx = 72, WEy = 72,0);
};
示例9: SetViewportOrgEx
void
gfxWindowsNativeDrawing::EndNativeDrawing()
{
if (mRenderState == RENDER_STATE_NATIVE_DRAWING) {
// we drew directly to the HDC in the context; undo our changes
SetViewportOrgEx(mDC, mOrigViewportOrigin.x, mOrigViewportOrigin.y, NULL);
if (mTransformType != TRANSLATION_ONLY)
SetWorldTransform(mDC, &mOldWorldTransform);
mWinSurface->MarkDirty();
mRenderState = RENDER_STATE_NATIVE_DRAWING_DONE;
} else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK) {
mBlackSurface = mWinSurface;
mWinSurface = nsnull;
mRenderState = RENDER_STATE_ALPHA_RECOVERY_BLACK_DONE;
} else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE) {
mWhiteSurface = mWinSurface;
mWinSurface = nsnull;
mRenderState = RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE;
} else {
NS_ERROR("Invalid RenderState in gfxWindowsNativeDrawing::EndNativeDrawing");
}
}
示例10: DrawYScale
BOOL DrawYScale(HDC hdc, RECT rect)
{
// Calculate dimensions
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
FillRect(hdc, &rect, GetStockObject(WHITE_BRUSH));
// Move the origin
SetViewportOrgEx(hdc, width / 2, height / 2, NULL);
// Draw scale
for (int y = 0; y < height / 2; y += 50)
{
MoveToEx(hdc, 0, y, NULL);
LineTo(hdc, width / 2, y);
MoveToEx(hdc, 0, -y, NULL);
LineTo(hdc, width / 2, -y);
}
for (int y = 0; y < height / 2; y += 10)
{
MoveToEx(hdc, width / 8, y, NULL);
LineTo(hdc, width / 2, y);
MoveToEx(hdc, width / 8, -y, NULL);
LineTo(hdc, width / 2, -y);
}
}
示例11: SetIsotropic
void SetIsotropic(HDC hdc, int cxClient, int cyClient)
{
SetMapMode(hdc, MM_ISOTROPIC);
SetWindowExtEx(hdc, 1000, 1000, NULL);
SetViewportExtEx(hdc, cxClient / 2, -cyClient / 2, NULL);
SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);
}
示例12: SetScale
//*******************************************************************
// helper to set scaling for print/preview
static void SetScale(HDC dc, int uthei, int utwi, const OUT_PAR * po)
{
int width, height, mul, div;
float yfact, xfact;
long left, right, low, high;
low = (int) (po->ymin - MARGIN);
high = (int) (po->ymax + MARGIN);
left = (int) po->xmin - MARGIN;
right = (int) po->xmax + MARGIN;
width = right - left;
height = high - low;
//to this point only used dest coords
yfact = uthei / (float) height;
xfact = utwi / (float) width;
SetMapMode(dc, MM_ANISOTROPIC);
if (fabs(yfact) < fabs(xfact)) {
div = height;
mul = uthei;
} else {
div = width;
mul = utwi;
}
SetViewportExtEx(dc, mul, -mul, NULL); // size mult
SetWindowExtEx(dc, div, div, NULL); // size divisor
SetWindowOrgEx(dc, left, high, NULL); // where was origo
SetViewportOrgEx(dc, 0, 0, NULL); // where do i want origo
}
示例13: SetMapMode
//-----------------------Render--------------------------------------
//
// given a GDI surface this function renders the ship and the
// landing pad
//-------------------------------------------------------------------
void CController::Render(HDC &surface)
{
//change the mapping mode so that the origin is at the bottom left
//of our window and so that the y axis increases as it goes from
//bottom to top
SetMapMode( surface, MM_ANISOTROPIC );
SetViewportExtEx( surface, 1, -1, NULL );
SetWindowExtEx( surface, 1, 1, NULL );
SetViewportOrgEx( surface, 0, m_cyClient, NULL );
//select in the pen we want to use
HPEN OldPen = (HPEN)SelectObject(surface, GetStockObject(WHITE_PEN));
//first render the stars
for (int i=0; i<m_vecStarVB.size(); ++i)
{
//add some twinkle
if (RandFloat() > 0.1)
{
SetPixel(surface, m_vecStarVB[i].x, m_vecStarVB[i].y, RGB(255, 255, 255));
}
}
//render the user controlled ship
m_pUserLander->Render(surface);
//render the landing pad...
RenderLandingPad(surface);
//return the mapping mode to its default state so text is rendered
//correctly
SetMapMode( surface, MM_ANISOTROPIC );
SetViewportExtEx( surface, 1, 1, NULL );
SetWindowExtEx( surface, 1, 1, NULL );
SetViewportOrgEx( surface, 0, 0, NULL );
//Render additional information
SetBkMode(surface, TRANSPARENT);
SetTextColor(surface, RGB(0,0,255));
string s= "Cursor Keys - Rotate Spacebar - Thrust R - Retry";
TextOutA(surface, 30, m_cyClient - 20, s.c_str(), s.size());
//replace the pen
SelectObject(surface, OldPen);
}
示例14: _ASSERTE
/**
* @param hdc - drawing conImage.
* @param prcPaint - the rectangle where the painting is requested.
*/
void CImageView::DrawImageView(HDC hdc, const RECT* prcPaint)
{
_ASSERTE(g_pResManager != NULL);
RECT rcClient;
GetClientRect(m_hwnd, &rcClient);
if (prcPaint == NULL)
prcPaint = &rcClient;
if (IsRectEmpty(prcPaint))
return;
#ifdef USE_MEM_DC
int nClientWidth = prcPaint->right - prcPaint->left;
int nClientHeight = prcPaint->bottom - prcPaint->top;
HBITMAP hbmpMem;
hbmpMem = CreateCompatibleBitmap(hdc, nClientWidth, nClientHeight);
if (hbmpMem == NULL)
return;
HDC hdcMem;
hdcMem = CreateCompatibleDC(hdc);
if (hdcMem == NULL)
{
DeleteBitmap(hbmpMem);
return;
}
SetViewportOrgEx(hdcMem, -prcPaint->left, -prcPaint->top, NULL);
HBITMAP hbmpSafe = SelectBitmap(hdcMem, hbmpMem);
#else
// CS_PARENTDC sets the clipping rectangle of the child window to that of the parent window
// so that the child can draw on the parent. Text view inherits this style from sub-classed
// static control. This causes problems with unclipped TabbedTextOut() output.
HRGN hrgn = CreateRectRgnIndirect(prcPaint);
SelectClipRgn(hdc, hrgn);
DeleteRgn(hrgn);
HDC hdcMem = hdc;
#endif
FillRect(hdcMem, prcPaint, g_pResManager->m_hbrWindowBrush);
HDC hdcTemp = CreateCompatibleDC(hdc);
if (hdcTemp)
{
HBITMAP hbmpSafe2 = SelectBitmap(hdcTemp, m_hAdjustedBitmap);
int nHorPos = GetScrollPos(m_hwnd, SB_HORZ);
int nVertPos = GetScrollPos(m_hwnd, SB_VERT);
int nImageLeft = rcClient.right > m_szAjustedBitmapSize.cx ? (rcClient.right - m_szAjustedBitmapSize.cx) / 2 : -nHorPos;
int nImageTop = rcClient.bottom > m_szAjustedBitmapSize.cy ? (rcClient.bottom - m_szAjustedBitmapSize.cy) / 2 : -nVertPos;
BitBlt(hdcMem, nImageLeft, nImageTop, m_szAjustedBitmapSize.cx, m_szAjustedBitmapSize.cy, hdcTemp, 0, 0, SRCCOPY);
SelectBitmap(hdcTemp, hbmpSafe2);
DeleteDC(hdcTemp);
}
#ifdef USE_MEM_DC
BitBlt(hdc, prcPaint->left, prcPaint->top, nClientWidth, nClientHeight, hdcMem, prcPaint->left, prcPaint->top, SRCCOPY);
SelectBitmap(hdcMem, hbmpSafe);
DeleteDC(hdcMem);
DeleteBitmap(hbmpMem);
#endif
}
示例15: setviewport
void setviewport(int x1, int y1, int x2, int y2, int clip)
{
view_settings.left = x1;
view_settings.top = y1;
view_settings.right = x2;
view_settings.bottom = y2;
view_settings.clip = clip;
if (hRgn) {
DeleteObject(hRgn);
}
hRgn = clip ? CreateRectRgn(x1, y1, x2, y2) : NULL;
SelectClipRgn(hdc[1], hRgn);
SetViewportOrgEx(hdc[1], x1, y1, NULL);
SelectClipRgn(hdc[0], hRgn);
SetViewportOrgEx(hdc[0], x1, y1, NULL);
moveto(0,0);
}