Пример #1
0
//*******************************************************************
// 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
}
Пример #2
0
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) ;
}
Пример #3
0
/***********************************************************************
 *           SetViewportExtEx    (GDI.479)
 */
BOOL16 WINAPI SetViewportExtEx16( HDC16 hdc, INT16 x, INT16 y, LPSIZE16 size )
{
    SIZE size32;
    BOOL16 ret = SetViewportExtEx( hdc, x, y, &size32 );
    if (size) { size->cx = size32.cx; size->cy = size32.cy; }
    return ret;
}
Пример #4
0
void startPrint(HWND hWnd, char *dirpath, char *filename, char* maptitle)
{
    char *pdfDriver = "Win2PDF";

    pdfDC = CreateDC("WINSPOOL", pdfDriver, NULL, NULL);
    if (!pdfDC) {
        error_stop("cannot open PDF driver: ", pdfDriver);
    }

    int horzres = GetDeviceCaps(pdfDC, HORZRES);
    int vertres = GetDeviceCaps(pdfDC, VERTRES);

    // Let's find the aspect ratio of the page
    double aspectRatio = (double) vertres / (double)horzres;

    pageWidth = DESIRED_PAGE_WIDTH;
    pageHeight = (int)((double)DESIRED_PAGE_WIDTH * aspectRatio);

    SetMapMode(pdfDC, MM_ISOTROPIC);
    SetViewportExtEx(pdfDC, horzres, vertres, NULL);
    SetWindowExtEx(pdfDC, pageWidth, pageHeight, NULL);

    DOCINFO docInfo = {0};
    docInfo.cbSize = sizeof(docInfo);

    char fullpath[MAX_PATH] = {0};
    strcpy_s(fullpath, sizeof(fullpath), dirpath);
    strcat_s(fullpath, sizeof(fullpath), filename);

    docInfo.lpszDocName = filename;
    docInfo.lpszOutput = fullpath;

    StartDoc(pdfDC, &docInfo);
    StartPage(pdfDC);
}
Пример #5
0
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);
}
Пример #6
0
void Fl_Gdi::fit(double x, double y, double w, double h, int align)
{


    double dx, dy;
    double pwp = pw_ - lm_ - rm_;
    double php = ph_ - tm_ - bm_;

    double s = pwp/w;
    if(s<(php/h)) {
        dx = 0;
        dy = (php - s * h)*iy/144;
    } else {
        s=php/h;
        dy =0;
        dx = (pwp - 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_ /72 - ox + dx), VOy = (int)( iy *tm_ /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);
};
Пример #7
0
bool EmfPaintEngine::begin(QPaintDevice* p)
{
	if (!p)
		return false;

	setPaintDevice(p);

	HWND desktop = GetDesktopWindow();
	HDC dc = GetDC(desktop);
	PCSTR description = "Metafile created\0with EmfEngine\0";

	metaDC = CreateEnhMetaFileA(dc, fname.toLocal8Bit().data(), &d_rect, description);//create null rectangle metafile

	d_rect.left = 0;
	d_rect.top = 0;
	d_rect.right = 100*p->width()*GetDeviceCaps(metaDC, HORZSIZE)/(double)GetDeviceCaps(metaDC, HORZRES);
	d_rect.bottom = 100*p->height()*GetDeviceCaps(metaDC, VERTSIZE)/(double)GetDeviceCaps(metaDC, VERTRES);

	end();//delete the dummy metafile

	metaDC = CreateEnhMetaFileA(dc, fname.toLocal8Bit().data(), &d_rect, description);

	SetWindowExtEx(metaDC, p->width(), p->height(), 0);
	SetViewportExtEx(metaDC, p->width(), p->height(), 0);

	return true;
}
Пример #8
0
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);
}
Пример #9
0
static void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
{
    SIZE windowExt, windowExtAfter, viewportExt;
    POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;

    GetWindowOrgEx(hdc, &windowOrg);
    GetViewportOrgEx(hdc, &viewportOrg);
    GetWindowExtEx(hdc, &windowExt);

    SetViewportExtEx(hdc, cx, cy, NULL);
    GetViewportExtEx(hdc, &viewportExt);
    ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
        "Viewport extents have not been properly adjusted: Expected %dx%d, got %dx%d\n",
        expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);

    GetWindowExtEx(hdc, &windowExtAfter);
    ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy,
       "Window extension changed from %dx%d to %dx%d\n",
       windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy);

    GetWindowOrgEx(hdc, &windowOrgAfter);
    ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
        "Window origin changed from (%d,%d) to (%d,%d)\n",
        windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);

    GetViewportOrgEx(hdc, &viewportOrgAfter);
    ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
        "Viewport origin changed from (%d,%d) to (%d,%d)\n",
        viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
}
Пример #10
0
/**
** Higher-level interface: Output Enhanced META File format (-m emf)
**/
int to_emf(const GEN_PAR * pg, const OUT_PAR * po)
{
	HANDLE outDC;
	int err = 0;
	if (!pg->quiet)
		Eprintf("\n\n- Writing emf code to \"%s\"\n",
			*po->outfile == '-' ? "stdout" : po->outfile);

	/* Init.  */

	if (*po->outfile != '-') {
		if ((outDC =
		     CreateEnhMetaFile(NULL, po->outfile, NULL,
				       "hp2xx\0\0")) == 0) {
			PError("hp2xx (emf)");
			return ERROR;
		}
	} else {
		PError("hp2xx (Cant send metafile to stdout emf)");
		return ERROR;
	}
	SetMapMode(outDC, MM_ANISOTROPIC);
	SetViewportExtEx(outDC, 10, -10, NULL);	// size mult
	err = plotit(outDC, pg, po);
	CloseEnhMetaFile(outDC);

	if (!pg->quiet) {
		Eprintf("\nlines=%d moves=%d", lines, moves);
		Eprintf("\n");
	}
	return err;
}
Пример #11
0
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);

};
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;
}
Пример #13
0
//-----------------------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
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static HMETAFILE hmf ;
     static int       cxClient, cyClient ;
     HBRUSH           hBrush ;
     HDC              hdc, hdcMeta ;
     int              x, y ;
     PAINTSTRUCT      ps ;
     
     switch (message)
     {
     case WM_CREATE:
          hdcMeta = CreateMetaFile (NULL) ;
          hBrush  = CreateSolidBrush (RGB (0, 0, 255)) ;
          
          Rectangle (hdcMeta, 0, 0, 100, 100) ;
          
          MoveToEx (hdcMeta,   0,   0, NULL) ;
          LineTo   (hdcMeta, 100, 100) ;
          MoveToEx (hdcMeta,   0, 100, NULL) ;
          LineTo   (hdcMeta, 100,   0) ;
          
          SelectObject (hdcMeta, hBrush) ;
          Ellipse (hdcMeta, 20, 20, 80, 80) ;
          
          hmf = CloseMetaFile (hdcMeta) ;
          
          DeleteObject (hBrush) ;
          return 0 ;
          
     case WM_SIZE:
          cxClient = LOWORD (lParam) ;
          cyClient = HIWORD (lParam) ;
          return 0 ;
          
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;
          
          SetMapMode (hdc, MM_ANISOTROPIC) ;
          SetWindowExtEx (hdc, 1000, 1000, NULL) ;
          SetViewportExtEx (hdc, cxClient, cyClient, NULL) ;
          
          for (x = 0 ; x < 10 ; x++)
          for (y = 0 ; y < 10 ; y++)
          {
               SetWindowOrgEx (hdc, -100 * x, -100 * y, NULL) ;
               PlayMetaFile (hdc, hmf) ;
          }
          EndPaint (hwnd, &ps) ;
          return 0 ;
               
     case WM_DESTROY:
          DeleteMetaFile (hmf) ;
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Пример #15
0
void MacPrinterCanvas::setmapmode(HDC hdc) {
	int s = int(1440./scale_);
	MWassert(SetMapMode(hdc, MM_ANISOTROPIC));
	//MWassert(SetWindowExtEx(hdc, 1440, 1440, NULL));
	MWassert(SetWindowExtEx(hdc, s, s, NULL));
	MWassert(SetViewportExtEx(hdc,
		GetDeviceCaps(hdc, LOGPIXELSX),
		-GetDeviceCaps(hdc, LOGPIXELSY),
		NULL));
}
Пример #16
0
/*****************************************************************************
 * Prepare the printer DC for output. This function uses the specified CPI
 * values to scale the DC, using MM_ANISOTROPIC mapping mode.
*****************************************************************************/
static void PrepareDC( void )
{
   int lpxlX = GetDeviceCaps( pd.hDC, LOGPIXELSX );
   int lpxlY = GetDeviceCaps( pd.hDC, LOGPIXELSY );

   SetMapMode( pd.hDC, MM_ANISOTROPIC );
   SetViewportExtEx( pd.hDC, lpxlX, lpxlY, NULL );
   SetWindowExtEx( pd.hDC, LOWORD( dwCPI ), HIWORD( dwCPI ), NULL );
   SetViewportOrgEx( pd.hDC, offsetx, offsety, NULL );

   SetBkMode( pd.hDC, TRANSPARENT );
   SetTextColor( pd.hDC, color );
}
Пример #17
0
void MainWindow::OnPaint(HDC hdc){
	HBRUSH brush = CreateSolidBrush(bground);
	SetMapMode(hdc, MM_ANISOTROPIC);
	RECT rc;
	GetClientRect(*this, &rc);
	SetViewportExtEx(hdc, rc.right, rc.bottom, NULL);
	SetWindowExtEx(hdc, x, y, NULL);
	for (int i = 0; i < x; ++i)
		for (int j =(i%2 ? 1 : 0); j < y; j+=2){
			RECT r = { i, j, i + 1, j + 1 };
			FillRect(hdc, &r, brush);
		}
		DeleteObject(brush);
}
Пример #18
0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
{
	static TCHAR szHeading[]	= TEXT("Mapping Mode            Left   Right     Top  Bottom");
	static TCHAR szUndLine[]	= TEXT("------------            ----   -----     ---  ------");
	static int cxChar, cyChar;
	HDC			hdc;
	PAINTSTRUCT	ps;
	TEXTMETRIC	tm;

	switch (message) {
	case WM_CREATE:
		hdc = GetDC(hwnd);
		SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));

		GetTextMetrics(hdc, &tm);
		cxChar = tm.tmAveCharWidth;
		cyChar = tm.tmHeight + tm.tmExternalLeading;

		ReleaseDC(hwnd, hdc);
		return 0;

	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);
		SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));

		SetMapMode(hdc, MM_ANISOTROPIC);
		SetWindowExtEx(hdc, 1, 1, NULL);
		SetViewportExtEx(hdc, cxChar, cyChar, NULL);

		TextOut(hdc, 1, 1, szHeading, lstrlen(szHeading));
		TextOut(hdc, 1, 2, szUndLine, lstrlen(szUndLine));

		Show(hwnd, hdc, 1, 3, MM_TEXT,		TEXT("TEXT (pixels)"));
		Show(hwnd, hdc, 1, 4, MM_LOMETRIC,	TEXT("LOMETRIC (.1mm)"));
		Show(hwnd, hdc, 1, 5, MM_HIMETRIC,	TEXT("HIMETRIC (.01mm)"));
		Show(hwnd, hdc, 1, 6, MM_LOENGLISH,	TEXT("LOENGLISH (.01in)"));
		Show(hwnd, hdc, 1, 7, MM_HIENGLISH,	TEXT("HIENGLISH (.001in)"));
		Show(hwnd, hdc, 1, 8, MM_TWIPS,		TEXT("TWIPs (1/1440in)"));

		EndPaint(hwnd, &ps);
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}
Пример #19
0
void OnPaint(HWND hWnd){
	PAINTSTRUCT ps = {0};
	HDC hdc = BeginPaint(hWnd,&ps);
	
	HPEN hPen = CreatePen(PS_DASH,10,RGB(255,0,0));
	//HBRUSH hBrush = CreateSolidBrush(RGB(0,255,0));
	//HGDIOBJ hBrush = GetStockObject(NULL_BRUSH);
	
	HBITMAP hBmp = LoadBitmap(g_hInstance,MAKEINTRESOURCE(IDB_BITMAP1));
	HBRUSH hBrush = CreatePatternBrush(hBmp);


	HGDIOBJ nOldPen = SelectObject(hdc,hBrush);

	int nOldMode = SetMapMode(hdc,MM_ISOTROPIC);
	SetWindowExtEx(hdc,1,1,NULL);
	SetViewportExtEx(hdc,1,2,NULL);

	switch(g_kind){
		case ID_ARC:
			DrawArc(hdc);
			break;
		case ID_POINT:
			DrawPoint(hdc);
			break;
		case ID_LINE:
			DrawLine(hdc);
			break;
		case ID_RECT:
			DrawRect(hdc);
			break;
		case ID_ROUNDRECT:
			DrawRoundRect(hdc);
			break;
		case ID_CIRCLE:
			DrawCircle(hdc);
			break;
		case ID_BMP:
			DrawBmp(hdc);
			break;
	}
	SelectObject(hdc,nOldPen);
	//DeleteObject(hPen);
	SetMapMode(hdc,nOldMode);
	EndPaint(hWnd,&ps);
}
Пример #20
0
void AtlMapZoom(ATL_DRAWINFO& di)
{
	// Quit if not zoomed
	if (!di.bZoomed)
		return;

	RECT& rc = *(RECT*)di.prcBounds;
	
	// Setup mapping mode...
	SetMapMode(di.hdcDraw, MM_ANISOTROPIC);
	SetViewportExtEx(di.hdcDraw, di.ZoomNum.cx, di.ZoomNum.cy, NULL);
	SetWindowExtEx(di.hdcDraw, di.ZoomDen.cx, di.ZoomDen.cy, NULL);
	SetWindowOrgEx(di.hdcDraw, rc.left, rc.top, NULL);
	SetViewportOrgEx(di.hdcDraw, rc.left, rc.top, NULL);

	// Scale bounds...
	rc.right=rc.left + (rc.right-rc.left) * di.ZoomDen.cx / di.ZoomNum.cx;
	rc.bottom=rc.top + (rc.bottom-rc.top) * di.ZoomDen.cy / di.ZoomNum.cy;
}
Пример #21
0
DrawEngine::DrawEngine(HDC hdc, HWND hwnd, int pxPerBlock,
                       int width, int height) :
    hdc(hdc), hwnd(hwnd), width(width), height(height)
{
    GetClientRect(hwnd, &rect);

    SaveDC(hdc);

    // Set up coordinate system
    SetMapMode(hdc, MM_ISOTROPIC);
    SetViewportExtEx(hdc, pxPerBlock, pxPerBlock, 0);
    SetWindowExtEx(hdc, 1, -1, 0);
    SetViewportOrgEx(hdc, 0, rect.bottom, 0);

    // Set default colors
    SetTextColor(hdc, RGB(255,255,255));
    SetBkColor(hdc, RGB(70,70,70));
    SetBkMode(hdc, TRANSPARENT);
}
Пример #22
0
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
	HDC hdc;
	PAINTSTRUCT ps;
	POINT ar[]={25,10,125,10,140,30,10,30,25,10};
	HBRUSH BrR, BrB, BrY, OldBr;
	RECT rect;

	switch(iMessage) {
	case WM_PAINT:
		hdc=BeginPaint(hWnd, &ps);
		BrR=CreateSolidBrush(RGB(255,0,0));
		BrB=CreateSolidBrush(RGB(0,0,255));
		BrY=CreateSolidBrush(RGB(255,255,0));

		SetMapMode(hdc,MM_ANISOTROPIC);
		SetWindowExtEx(hdc,160,100,NULL);
		GetClientRect(hWnd, &rect);
		SetViewportExtEx(hdc,rect.right,rect.bottom,NULL);

		OldBr=(HBRUSH)SelectObject(hdc,BrR);
		Rectangle(hdc,20,30,130,90);
		SelectObject(hdc,BrB);
		Polygon(hdc,ar,5);

		SelectObject(hdc,BrY);
		Rectangle(hdc,30,40,60,70);
		Rectangle(hdc,90,40,120,70);
		Ellipse(hdc,135,5,155,25);

		SelectObject(hdc,OldBr);
		DeleteObject(BrR);
		DeleteObject(BrB);
		DeleteObject(BrY);
		EndPaint(hWnd, &ps);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
Пример #23
0
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch( msg )
	{
	case WM_PAINT:
		{
			PAINTSTRUCT ps;

			HDC hdc = BeginPaint(hwnd, &ps);
			// 맵핑 모드 변경
			SetMapMode(hdc, MM_ISOTROPIC);	// 가변 모드로 변경...MM_ANISOTROPIC
//			SetMapMode(hdc, MM_LOENGLISH);	// 비례 가변 모드.. MM_ISOTROPIC


			// 현재 클라이언트의 크기 
			RECT r;
			GetClientRect(hwnd, &r);
			int cx = r.right	- r.left;	// 폭
			int cy = r.bottom	- r.top;	// 높이

			// 논리 좌표의 크기 고정( 윈도우의 범위를 100, 100으로 지정)
			// 논리 좌표 : Window라고도 부름 
			//             논리 좌표가 사용되는 표현(내부적으로 그래픽 출력)
			SetWindowExtEx(hdc, 100, 100, 0);

			// 물리좌표의 크기는 클라이언트의 크기로 지정.
			// 물리 좌표 : viewport라고도 부름
			//             눈에 보이는 좌표 영역 
			SetViewportExtEx(hdc, cx, cy, 0);

			Rectangle(hdc, 10, 10, 90, 90 );
			EndPaint(hwnd, &ps);
		}
		return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
Пример #24
0
void Fl_Gdi::set_page(int page)
{
    DEVMODE * mode = (DEVMODE *) GlobalLock(mode_);
    if(page) {
        ResetDC(gc_,mode);
        SetMapMode(gc_, MM_ANISOTROPIC);
        SetTextAlign(gc_, TA_BASELINE|TA_LEFT);
        SetBkMode(gc_, TRANSPARENT);
        StartPage(gc_);
        ix = GetDeviceCaps(gc_, LOGPIXELSX);
        iy = GetDeviceCaps(gc_, LOGPIXELSY);
        ox = GetDeviceCaps(gc_, PHYSICALOFFSETX);
        oy = GetDeviceCaps(gc_, PHYSICALOFFSETY);
    }
    GlobalUnlock(mode_);

    SetViewportOrgEx(gc_,VOx = (int)(ix * lm_ /72 - ox), VOy =(int)( iy *tm_ /72 - oy),0); //setting origin to the upper left corner inside margins
    SetViewportExtEx(gc_, VEx = (int)(ix * pw_ / 72),  (int)(VEy = iy * ph_ / 72),0);
    SetWindowExtEx(gc_, WEx = (int) pw_,  WEy = (int)ph_,0); //72 pixels per inch mapping
    SetWindowOrgEx(gc_, WOx = 0, WOy = 0,0);
}
Пример #25
0
void Fl_Gdi::place(double x, double y, double w, double h, double tx, double ty, double tw, double th, double dpi, int align)
{
    double s = 72/dpi;
    double dy = (th - s * h)*iy/144;
    double 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_+ty) /72 - oy + dy),0);
    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);
};
Пример #26
0
void Printer::Print(Window *Obj)
{
	if (PrintDialog(Obj,PD_RETURNDC))
	{
		RECT Client;
		GetClientRect(Obj->hWnd,&Client);

		SetMapMode(pd.hDC, MM_ANISOTROPIC);
		SetWindowExtEx(pd.hDC, Client.right, Client.bottom,NULL);
		SetViewportExtEx(pd.hDC, GetDeviceCaps(pd.hDC,HORZRES),GetDeviceCaps(pd.hDC,VERTRES),NULL);

		DOCINFO dInfo={sizeof(DOCINFO),"Test-Doc",NULL};
		StartDoc(pd.hDC,&dInfo);
		StartPage(pd.hDC);

		Obj->Paint(pd.hDC,FALSE,Client);

		EndPage(pd.hDC);
		EndDoc(pd.hDC);

		DeleteDC(pd.hDC);
	}
}
Пример #27
0
Файл: s.cpp Проект: Siemko/PIU
// OBS£UGA ZDARZEÑ
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	switch( msg )
	{
	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc = BeginPaint(hwnd, &ps);

			RECT screen;
			GetClientRect(hwnd, &screen);
			SetMapMode(hdc, MM_ANISOTROPIC);
			SetWindowExtEx(hdc, 700, 500, 0);
			SetViewportExtEx(hdc, screen.right, screen.bottom, 0);
			
			Test.draw(hdc);
			//tiles->draw(hdc);
			EndPaint(hwnd, &ps);
		}
		break;
	case WM_CLOSE:
		{
		DestroyWindow( hwnd );
		break;
		}
	case WM_DESTROY:
		{
		PostQuitMessage( 0 );
		break;
		}
	default:
		return DefWindowProc( hwnd, msg, wParam, lParam );
	}

	return 0;
}
Пример #28
0
void CDC::MapMode(const CSize& rDeviceUnits, const CSize& rLogicalUnits)
{
	MapMode(MM_ANISOTROPIC);
	SetWindowExtEx(m_hDC,   rLogicalUnits.cx, rLogicalUnits.cy, NULL);
	SetViewportExtEx(m_hDC, rDeviceUnits.cx,  rDeviceUnits.cy, NULL);
}
Пример #29
0
void CSurfaceView::OnDraw(CDC* pDC) 
{
//	return;
	// TODO: Add your specialized code here and/or call the base class
//	if(!CGeneral::RaftArray.size())	return;
	if(CGeneral::step == 0) return;
	CGeneral::is_draw_finished = false;

	clock_t startd, find;
	double	duration = 0;
	startd = clock();
	//yellow, cremovi
	static 	COLORREF colors[255*255*255];
	for(int r=0; r<255 ; r++)	{
		for(int g=0; g<255 ; g++)	{
			for(int b=0; b<255 ; b++)	{
				colors[r+g+b]= RGB( 255-r, 255-g, 255-b);
			}
		}
	}


	static 	COLORREF col[16] = { RGB( 255, 0, 0 ), RGB( 0, 255, 0 ), //krasnii-0, zelyonii-1
		RGB( 0, 0, 255), RGB( 0, 255, 255 ), //sinii-2, goluboiCian-3
		RGB( 255, 0, 255), RGB( 255, 255, 0 ), //malinovii-4, jyoltii-5
		RGB( 192, 192, 192), RGB( 80, 0, 80 ), //serii-6, t-malinovii-7
		RGB( 255, 255, 255), RGB( 80, 80, 0 ), //serii-8, t-jyoltii-9, 
		RGB( 80, 80, 0 ), RGB( 0, 0, 80 ), //4yornii-10, tyomn. golub - 11 
		RGB( 250, 166, 70 ), RGB( 207, 10, 243 ), //orange-12, tyomn. fioletovii - 13 
		RGB( 128, 128, 0 ), RGB( 0, 0, 0 )}; // seri 15

	GetClientRect(m_ClientRect );
	int oldBkMode = pDC->SetBkMode(TRANSPARENT);
	
	static int key = 1;

	DrawSize = (m_ClientRect.Width( ) < m_ClientRect.Height( ) )
		? m_ClientRect.Width( ) : m_ClientRect.Height( ) ;
	if(DrawSize > GRID_SIZE)  DrawSize = GRID_SIZE;
	else
	{	
		minZoom = (GRID_SIZE-1)/DrawSize + 1 ;
		if(m_PartGrid < minZoom)
		{
			m_PartGrid = minZoom;
		}
	}
	DrawSize = GRID_SIZE/m_PartGrid;
	m_OptionDlg->SetZoom(m_PartGrid, GRID_SIZE/m_PartGrid,num);
	int xp = (m_PartGridNum - 1)%m_PartGrid ;
	int yp = (m_PartGridNum - 1) / m_PartGrid ;
	X = 0 + DrawSize * xp;
	Y = 0 + DrawSize * yp;
	X1 = X + DrawSize; 
	Y1 = Y + DrawSize;


//-----------------------------------------------------------------		
	CDC * myDc;
	CDC memdc;
	CBitmap bmp, *poldbmp;
	isMemDc = IsMemDc && !( CGeneral::DrawRaftIndexes 
		|| CGeneral::DrawRecIndexes
		|| CGeneral::DrawSigMolInd || CGeneral::DrawSigMolNames
		|| CGeneral::DrawRecNames);

	if(isMemDc)
	{
		// Create a compatible memory DC
		memdc.CreateCompatibleDC( pDC);
		bmp.CreateCompatibleBitmap (pDC, m_ClientRect.Height(), m_ClientRect.Height()); 
		//bmp.CreateCompatibleBitmap (pDC, DrawSize, DrawSize); 
		// Select the new bitmap object into the memory device context. 
		poldbmp = memdc.SelectObject( &bmp );

		memdc.BitBlt( 0,0,m_ClientRect.Height(), m_ClientRect.Height(),&memdc, 0, 0, WHITENESS );  
		myDc = &memdc;
	}
	else myDc = pDC;
	myDc->SetMapMode(MM_ISOTROPIC);
	SetWindowExtEx(*myDc,DrawSize,DrawSize,NULL);
	SetViewportExtEx(*myDc,m_ClientRect.right, -m_ClientRect.bottom,NULL);
	SetViewportOrgEx(*myDc,0,m_ClientRect.bottom,NULL);	
//-----------------------------------------------------------------		





	double sd = sqrt(DrawSize /27.) ;

	if( CGeneral::DrawSigMol ){

		double sd_sm = sd-1;
		if(sd_sm < 1) sd_sm = 1; //   ?????????????????

		CBrush br;
		br.CreateSolidBrush(col[1]);

		for(int in=0; in<GRID_SIZE ; in++)
		{
			for(int in1=0; in1<GRID_SIZE ; in1++)
			{
				CBrush br1;
				double IFN_prot_conc = CGeneral::grid.m_Grid[in1][in].array[SM];
				if(IFN_prot_conc == 0){
					continue;
				}
				int normalized_IFN_prot_conc = floor(IFN_prot_conc);
				br1.CreateSolidBrush(colors[normalized_IFN_prot_conc]);
				CBrush* pSMBr = myDc->SelectObject( &br1 );

	//			myDc->Rectangle(in - X, in1 -Y,	in + sd_sm -X, in1 + sd_sm - Y); 
				CRect rect(in - X, in1 -Y, in + sd_sm -X, in1 + sd_sm - Y);
				myDc->FillRect(&rect ,&br1); 

				if(CGeneral::DrawSigMolNames)
				{
					char buf[30] = "IFNprot: ";
					char buf5[10];
					itoa(IFN_prot_conc,buf5,10);
					strncat(buf, buf5, 10);//add coma
					myDc->TextOut(in - X, in1 -Y, buf, strlen(buf));
				}	

			}
		}

	}



	/////////////////// begin drawing rafts //////////////////////////////////
	if( CGeneral::DrawRafts )
	{
		CBrush gray_hatch_br, red_br, grey_br;
		gray_hatch_br.CreateHatchBrush(HS_BDIAGONAL, col[15]);
		grey_br.CreateSolidBrush(col[15]);
		red_br.CreateSolidBrush(col[1]);


		CBrush* pOldBr = myDc->SelectObject( &gray_hatch_br );

		std::vector<CCell>::iterator raft_iter;
		raft_iter = CGeneral::CellArray.begin();
		CCell * p_Raft = raft_iter;
		for(; raft_iter  != CGeneral::CellArray.end(); raft_iter++)
		{
			p_Raft = raft_iter;



			double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
//			double normalized_rigI_rna_conc = rigI_rna_conc/CGeneral::RIGI_rna_maxLevel;
			double IFN_prot_conc = p_Raft->GetIFN_prot_conc();
//			double normalized_IFN_prot_conc = IFN_prot_conc/CGeneral::IFN_prot_maxLevel;

			if( p_Raft->IsActivated() )
			{
				CBrush br;
 				double RIGI_rna_conc = p_Raft->GetRIGI_rna_conc();
				int val=0;
				if(CGeneral::DrawAgs)
					double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
				else
					double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();


				if( !p_Raft->IsInfected() )//not infected
				{
					br.CreateHatchBrush(HS_BDIAGONAL, RGB( 128, 128, 128 ));
					CBrush* pSMBr = myDc->SelectObject( &br );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x  -X, p_Raft->Location.y - Y); 

				} 	           
				else// infected
				{
					if( CGeneral::step != 1)
					{
						CBrush* pSMBr = myDc->SelectObject( &red_br );
						myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
									p_Raft->Location.x  -X, p_Raft->Location.y  - Y); 
					}
					if(p_Raft->m_blinking_counter == p_Raft->m_blinking_const)
					{
						p_Raft->m_blinking_counter = 0;
						p_Raft->m_justChangedStatus = !p_Raft->m_justChangedStatus;
					}
					else{p_Raft->m_blinking_counter++;}

					br.CreateSolidBrush(RGB( 128, 128, 128 ));
					CBrush* pSMBr = myDc->SelectObject( &br );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X, p_Raft->Location.y - Y); 
					if(p_Raft->m_blinking_counter == p_Raft->m_blinking_const)
					{
						p_Raft->m_blinking_counter = 0;
						p_Raft->m_justChangedStatus = !p_Raft->m_justChangedStatus;
					}
					else{p_Raft->m_blinking_counter++;}
				}

			} // if	                 
			else // not activated
			{
				CBrush brt,brt1;
				int val_msg;
				int val_prot;
				if(!CGeneral::DrawAgs) {//DDX58
//					if(CGeneral::DrawAgIndexes)//msg
						val_msg = p_Raft->GetRIGI_rna_conc();
//					else //prot
						val_prot = p_Raft->GetRIGI_prot_conc();
				}
				else {//IFNB1
//					if(CGeneral::DrawAgIndexes)//IFNB1
						val_msg = p_Raft->GetIFN_rna_conc();
//					else   //prot
						val_prot = p_Raft->GetIFN_prot_conc();
				}

				if( p_Raft->IsInfected() )//NOT UNFECTED		
				{
					brt.CreateSolidBrush(colors[val_prot]);
					CBrush* pSMBr = myDc->SelectObject( &brt );
					myDc->Ellipse(p_Raft->Location.x - X-1, p_Raft->Location.y -Y-1,
								p_Raft->Location.x -X+sd+1, p_Raft->Location.y  - Y+sd+1); 

					brt1.CreateSolidBrush(colors[val_msg]);
					pSMBr = myDc->SelectObject( &brt1 );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X+sd, p_Raft->Location.y  - Y+sd); 

/*					myDc->SetTextColor(col[0]); 
					char buf[30] = "*";
					myDc->TextOut(p_Raft->Location.x - X+1, p_Raft->Location.y -Y+1, 
						buf, strlen(buf));
						*/

				} // if	  
				else//not infected
				{	
//					brt.CreateSolidBrush(colors[col[2]]);
					brt.CreateHatchBrush(HS_BDIAGONAL, colors[val_prot]);
					CBrush* pSMBr = myDc->SelectObject( &brt );
					myDc->Ellipse(p_Raft->Location.x - X-1, p_Raft->Location.y -Y-1,
								p_Raft->Location.x -X+sd+1, p_Raft->Location.y  - Y+sd+1); 

					brt1.CreateHatchBrush(HS_FDIAGONAL, colors[val_prot]);
					pSMBr = myDc->SelectObject( &brt1 );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X+sd, p_Raft->Location.y  - Y+sd); 
				}
				
			}
			myDc->SetTextColor(col[0]); 
			int boundTypeIR = p_Raft->Get_boundTypeIR();
			if(boundTypeIR)	{
				char buf1[3] = "|";
				char buf2[3] = "--";
				char buf3[3]="";
				char buf[30] = "";
				char buf5[10];
				if((boundTypeIR%2)){
					strncat(buf3, buf1, 3);//add coma					
				}else{
					strncat(buf3, buf2, 3);//add coma					
				}
				myDc->TextOut(p_Raft->Location.x - X+1, p_Raft->Location.y -Y+1, 
					buf3, strlen(buf3));
			}
			myDc->SetTextColor(RGB(0,0,0)); 

			if( !p_Raft->IsInfected() ) {//not infected
			

			} 	           
			else {// infected
			
			}

			/*

			double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
			double normalized_rigI_rna_conc = rigI_rna_conc/CGeneral::RIGI_rna_maxLevel;
			double IFN_rna_conc = p_Raft->GetIFN_rna_conc();
			double normalized_IFN_rna_conc = IFN_rna_conc/CGeneral::IFN_rna_maxLevel;

			int sd_rna = sd+3;
			int val;
			if(CGeneral::DrawAgs)
				val = 255 - normalized_rigI_rna_conc * 255;
			else
				val = 255 - normalized_IFN_rna_conc * 255;
			CBrush br_rna;
			br_rna.CreateSolidBrush(RGB( val, val, val ));
			CBrush* pSMBr = myDc->SelectObject( &br_rna );
//			myDc->Ellipse(p_Raft->m_shape.Centroid().x - X, p_Raft->m_shape.Centroid().y -Y,
//				p_Raft->m_shape.Centroid().x + sd_rna -X, p_Raft->m_shape.Centroid().y + sd_rna - Y); 

*/



			if(CGeneral::DrawRaftIndexes)
			{
				char buf[30]="";
				char buf5[10]="";
				if(!CGeneral::DrawAgs){
//					if(CGeneral::DrawAgIndexes)	{
						strncat(buf, "DDX58: ", 10);//add coma
						itoa(p_Raft->GetRIGI_rna_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
//					else{
						strncat(buf, ", RIGI: ", 10);//add coma
						itoa(p_Raft->GetRIGI_prot_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
				}
				else{
//					if(CGeneral::DrawAgIndexes)	{
						strncat(buf, "IFNB:", 10);//add coma
//						buf = "IFNB: ";
						itoa(p_Raft->GetIFN_rna_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
//					else{
/*						strncat(buf, ", IFNb:", 10);//add coma
						itoa(p_Raft->GetIFN_prot_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));*/
//					}

				}
			}

		}
		myDc->SelectObject( pOldBr);
		num++;
		myDc->SetBkMode(oldBkMode);
	}
//------------------------ end drawing rafts ---------------------------//

	
	if(isMemDc)
	{
		pDC->StretchBlt( 0,0,m_ClientRect.Height( ) ,m_ClientRect.Height( ),&memdc, 0, 0,
			DrawSize, DrawSize, SRCCOPY); 
		//pDC->BitBlt( 0,0,DrawSize, DrawSize,&memdc, 0, 0, SRCCOPY ); 
		bmp.DeleteObject();
		memdc.DeleteDC();
	}
	pDC->SetBkMode(oldBkMode);

	CGeneral::is_draw_finished = true;
	if(stepGl == 10 || stepGl == 1000 || stepGl == 10000
		|| stepGl == 100000 || stepGl == 300000 || stepGl == 2000000)
	{
		find = clock();
		duration = (double)(find - startd) / CLOCKS_PER_SEC;	
//		CGeneral::out << "\n Draw duration " << duration << " step " << stepGl << endl;
	}
}
Пример #30
0
/* Also sets radius variable used to draw points.
 */
static void
handleInit(HWND hDlg)
{
   RECT winSize;
	 	RECT drawSize;
		 int orig_x,orig_y,ext_x,ext_y;
	 	//char mess [240]; /*used for debugging message text*/
   //hdc = GetDC(hDlg);


   jointlist = make_dl();
   pointlist = make_dl();


			GetWindowRect(hDlg, &winSize);
			GetWindowRect(GetDlgItem(hDlg,IDC_DRAWSPACE), &drawSize);
			hdc = GetDC(GetDlgItem(hDlg,IDC_DRAWSPACE)); /*get device context of the draw area*/

			SetClassLong(GetDlgItem(hDlg,IDC_DRAWSPACE), GCL_HCURSOR, (long)LoadCursor(NULL,"IDC_CROSS "));

			hCurrentPen = drawPen[1];  // black
			
			SetMapMode(hdc, MM_ISOTROPIC);
						
  /*
			sprintf(mess, "Dialog top is %d bottom is %d\nDraw top is %d bottom is %d.\n\nClick to continue.", 
									winSize.top,winSize.bottom,drawSize.top,drawSize.bottom);
			MessageBox( hDlg, mess, "Geometry: Window Size", MB_ICONINFORMATION );
		 */
	
			orig_x= drawSize.left-winSize.left;
			orig_y= drawSize.top-winSize.top;
			ext_x=drawSize.right-drawSize.left;
			ext_y=drawSize.bottom-drawSize.top;

			
			SetWindowOrgEx(hdc,orig_x,orig_y, NULL);
			SetWindowExtEx(hdc,ext_x,ext_y,NULL);

			// want square area to draw in

			maxSize = ext_x-orig_x; /*> ury-lly ? urx : ury;*/
			if (ury-lly>maxSize) 
      maxSize=ext_y-orig_y; 


			SetViewportOrgEx(hdc,orig_x,ext_y-orig_y-1, NULL); /*device units*/
			SetViewportExtEx(hdc, maxSize, -maxSize, NULL); /*device units*/
  /*
			sprintf(mess, "Viewport origin x is %d y is %d\nExtent x is %d y is %d.\n\nClick to continue.", 
									orig_x,ext_y-orig_y-1,maxSize,-maxSize);
			MessageBox( hDlg, mess, "Geometry: Window Size", MB_ICONINFORMATION );
			*/
//			EnableOpenGL (hDlg, &hdc, &hRC1);
//			hRC1 = wglCreateContext( hdc );
//			wglMakeCurrent( hdc, hRC1 );
//			glViewport (drawSize.left,drawSize.top,urx,ury);
//			glViewport (0,0,urx, ury);
//			glMatrixMode (GL_PROJECTION);
//			glLoadIdentity();
//			gluOrtho2D(0.0,1.0,1.0,0.0);
//			glutMouseFunc(Mouse);
			
			   
			radius = (int) ((urx-llx)/20);
			SetDlgItemInt(hDlg,IDC_MINX,llx,TRUE);
			SetDlgItemInt(hDlg,IDC_MINY,lly,TRUE);
			SetDlgItemInt(hDlg,IDC_MAXX,urx,TRUE);
			SetDlgItemInt(hDlg,IDC_MAXY,ury,TRUE);
			SetDlgItemInt(hDlg,IDC_GRID,gridSp,TRUE);
			ScaleX=Scale(urx,llx);
			ScaleY=Scale(ury,lly);
			CheckRadioButton(hDlg, DD_J1, DD_HP, DD_J1);
			CheckRadioButton(hDlg, DD_GRON, DD_GROFF, DD_GROFF);
 
			if(jp) 
				free(jp);
			if(pp) 
				free(pp);

			jp = (Joint *) malloc(sizeof(Joint) * estNumJts);
			pp = (DPoint *) malloc(sizeof(DPoint) * estNumPts);

			nLines=0; nPoints=0; nfp=0; nmp=0; nlp=0; nhp=0;
			tool=0; type=1; inside = TRUE;

//   if (grid == TRUE)
//      SendMessage(hDlg, WM_COMMAND, DD_GRON, 0L);

			//ReleaseDC(hDlg, hdc);

}  /* close handleInit() */