Пример #1
0
void SCALE::RepaintBitmap(HWND hwnd)
{
	HDC hdc ;
	PAINTSTRUCT ps ;
	HPALETTE    hpalOld;

	hdc = BeginPaint (hwnd, &ps) ;
	SetViewportOrg(hdc, -nHfirstPixel,-nVfirstPixel) ;
	if (PaletteCls::GetPaletteHandle ())
	  {
		hpalOld = SelectPalette (hdc, PaletteCls::GetPaletteHandle(), TRUE) ;
		RealizePalette (hdc) ;  
	  }

	if (scaleData.hScale)
		PaintDIBitmap (hdc, scaleData.hScale, &scaleData.rect) ;

	if (indData.hIndicator)
  	{
		PaintDIBitmap (hdc, indData.hIndicator, &indData.minRect) ;
		PaintDIBitmap (hdc, indData.hIndicator, &indData.maxRect) ;
		DrawIndText (hdc, scaleData.rect, indData.maxRect, 0) ;
		DrawIndText (hdc, scaleData.rect, indData.minRect, 1) ;
		}
	if (PaletteCls::GetPaletteHandle())
	  {
	  SelectPalette (hdc, hpalOld, TRUE) ;
		RealizePalette (hdc) ;
	  }

	EndPaint (hwnd, &ps) ;
	GetScrollRange (scaleData.rect, indData.minRect, indData.maxRect) ;
	ScaleSetScrollPos (hwnd) ;
}
Пример #2
0
/////////////////////////////////////////////////////////////////////
// TMapDC
// ------
//
void
TMapDC::SetupOrg()
{
#ifdef WINDOWS_SCALING
	// Set window and viewport scale and extension
	SetMapMode (MM_ANISOTROPIC);
	SetViewportOrg (TPoint(ScrCenterX, ScrCenterY));
	SetWindowOrg (TPoint(OrigX, OrigY)) ;
	if ( Scale > 1.0 )
	{
		// dc.SetWindowExt (TSize(ScrMaxX, ScrMaxY));
		// dc.SetViewportExt (TSize(ScrMaxX * MUL_SCALE, -ScrMaxY * MUL_SCALE));
		SetWindowExt (TSize(1, 1));
		SetViewportExt (TSize(MUL_SCALE, -MUL_SCALE));
	}
	else if (Scale <= 1.0 )
	{
		SetWindowExt (TSize(ScrMaxX * DIV_SCALE, ScrMaxY * DIV_SCALE));
		SetViewportExt (TSize(ScrMaxX, -ScrMaxY));
	}

	/*
	for (int x = MIN_MAP_X ; x <= MAX_MAP_X ; x+=1000)
		for (SHORT y = MIN_MAP_Y ; y <= MAX_MAP_Y ; y+=1000)
		{
			char msg[80];
			wsprintf (msg,"(%d:%d)", x/1000, y/1000);
			dc.TextOut (x, y, msg);
		}
	*/

#endif
}
Пример #3
0
/*
 * PaintMonitor - redraw the monitor window
 */
static void PaintMonitor( HWND hwnd, HDC dc, LocalMonInfo *info ) {

    RECT        area;
    WORD        i;
    char        buf[80];
    WORD        xpos, ypos;
    HBRUSH      white;

    SaveDC( dc );
    GetClientRect( hwnd, &area );
    white = GetStockObject( WHITE_BRUSH );
    FillRect( dc, &area, white );
    SetMapMode( dc, MM_ANISOTROPIC );
    SetWindowOrg( dc, 0, 0 );
    SetWindowExt( dc, MONITOR_WIDTH, MONITOR_HITE );
    SetViewportOrg( dc, 0, 0 );
    SetViewportExt( dc, area.right, area.bottom );

    area.top = BAR_HITE;
    area.bottom = 2 * BAR_HITE;
    area.left = BAR_XPOS;
    for( i=0; i < SIZE_CNT; i++ ) {
        if( info->sizes[i] == 0 ) continue;
        area.right = area.left + SECTION_WIDTH( info->sizes[i],
                                                info->total_size );
        FillRect( dc, &area, Brushes.brush[i] );

        xpos = ( area.left + area.right ) / 2;
        MoveTo( dc, xpos, area.bottom );
        ypos = area.bottom + TEXT_SPACE + ( SIZE_CNT - i ) * TEXT_HITE;
        LineTo( dc, xpos, ypos );
        xpos += TICK_LENGTH;
        LineTo( dc, xpos, ypos );
        if( i == STACK_SIZE ) {
            sprintf( buf, MonitorLabels[i], info->sizes[i],
                     info->stack_used );
        } else {
            sprintf( buf, MonitorLabels[i], info->sizes[i] );
        }
        TextOut( dc, xpos, ypos, buf, strlen( buf ) );
        area.left = area.right;
    }

    area.left = BAR_XPOS;
    area.right = area.left + BAR_LENGTH;
    MoveTo( dc, area.left, area.top );
    LineTo( dc, area.right, area.top );
    LineTo( dc, area.right, area.bottom );
    LineTo( dc, area.left, area.bottom );
    LineTo( dc, area.left, area.top );

    TextOut( dc, 0, BAR_HITE, "0", 1 );
    sprintf( buf, "%u", info->total_size );
    TextOut( dc, area.right + area.left, BAR_HITE, buf, strlen( buf ) );
    RestoreDC( dc, -1 );
}
Пример #4
0
/**********************************************************************
        SetELightMapping
**********************************************************************/
static int SetupRLightMapping(HWND hWnd, HDC hDC, WORD wMaxWidth,
                              WORD wTextHeight, WORD wNumPossValues)
{
    short sXWinExt, sYWinExt, sXWinOrg, sYWinOrg;
    short sXViewExt, sYViewExt, sXViewOrg, sYViewOrg;
    RECT rect;

    SetMapMode(hDC, MM_ISOTROPIC);

    sYWinExt = wNumPossValues * ((2 * VERT_PAD) + wTextHeight)
        + (2 * VERT_PAD) + wTextHeight;
    sXWinExt = wMaxWidth + (2 * VERT_PAD);

    /* Get clients rectangle */
    GetClientRect(hWnd, (LPRECT) & rect);

    sXViewExt = rect.right - rect.left;
    sYViewExt = rect.bottom - rect.top;

    if (sXViewExt > sXWinExt)
        sXViewOrg = rect.left + (short) ((double) sXViewExt / 2.0);
    else
        sXViewOrg = rect.left + (short) ((double) sXWinExt / 2.0);

    if (sYViewExt > sYWinExt)
        sYViewOrg = rect.bottom -
            (short) ((double) (sYViewExt - sYWinExt) / 2.0);
    else
        sYViewOrg = rect.bottom;

    sXWinOrg = 0;
    sYWinOrg = 0;

    /* Set the mappings */
    SetWindowExt(hDC, sXWinExt, sYWinExt);
    SetWindowOrg(hDC, sXWinOrg, sYWinOrg);

    SetViewportExt(hDC, sXWinExt, -sYWinExt);
    SetViewportOrg(hDC, sXViewOrg, sYViewOrg);

    return TRUE;
}
Пример #5
0
/*
*       -- 更改坐标系 --
*       ViewOrg_X, ViewOrg_Y: 视图原点; ViewExt_X, ViewExt_Y:  视图范围;
*       WindOrg_X, WindOrg_Y: 视图原点; WindExt_X, WindExt_Y: 窗口范围
*/
void  ChangeZBX(HDC hdc, int ViewOrg_X, int ViewOrg_Y, int ViewExt_X, int ViewExt_Y, int WindOrg_X, int WindOrg_Y, int WindExt_X, int WindExt_Y)
{
        POINT Pt_ViewOrg;
        POINT Pt_ViewExt;
        POINT Pt_WindExt;
        POINT Pt_WindOrg;
        
        
        Pt_ViewOrg.x = ViewOrg_X;
        Pt_ViewOrg.y = ViewOrg_Y;
        Pt_ViewExt.x = ViewExt_X;
        Pt_ViewExt.y = ViewExt_Y;
        Pt_WindOrg.x = WindOrg_X;
        Pt_WindOrg.y = WindOrg_Y;
        Pt_WindExt.x = WindExt_X;
        Pt_WindExt.y = WindExt_Y;
        
        SetMapMode(hdc, MM_ANISOTROPIC);
        SetViewportOrg(hdc, &Pt_ViewOrg);
        SetViewportExt(hdc, &Pt_ViewExt);
        SetWindowExt(hdc, &Pt_WindExt);
        SetWindowOrg(hdc, &Pt_WindOrg );
}
Пример #6
0
//*************************************************************************
// DoPaint -- this is the WM_PAINT action routine for the main window.
// It places the TrueType logo in the upper left corner of the window, draws
// a "fan hub" around it, and draws "fan leaves" of text out from the hub.
// These leaves are scaled to reach the bottom and the right edge of the
// window, by defining an ellipse centered on the TrueType logo which just
// touches those two edges.  The text strings span the distance from the
// hub to the ellipse along radial lines, and are both scaled and rotated.
//     Depending on user-set state variables, the ellipse and baselines
// for the text fan may be shown (ShowAlignmentMarks), and/or the text may
// be shadowed (ShadowAll).  Other attributes, such as bolding or
// italicization, may be selected from the font dialog box.
//*************************************************************************
void DoPaint()
{
    PAINTSTRUCT       PaintInfo;
    HDC               hDC;
    LOGFONT           FontRec;
    OUTLINETEXTMETRIC FontMetric;
    int               FontHeight, x, y, j, k;
    WORD              BaseWidth, DesiredExtent, FanTextLen;
    float             Theta;
    LPCSTR            P;
    RECT              R;
    long              TE;
    int               d;

    BeginPaint(hwnd, &PaintInfo);

    hDC = PaintInfo.hdc;
    P = ArcText;
    FanTextLen = strlen(FanText);

    // save device context; easiest way to preserve current state
    SaveDC(hDC);

    // set initial font data (for TrueType logo)
    FontRec = CornerFontRec;
    SetBkMode(hDC, TRANSPARENT);
    SetTextColor(hDC, RGB(128,128,128));
    FontRec.lfHeight = FontRec.lfHeight * 2;
    FontRec.lfWidth = floor(FontRec.lfWidth * 2.1);

    // create the TrueType logo
    SelectObject(hDC, CreateFontIndirect(&FontRec));
    TextOut(hDC, 18, 5, "T", 1);
    SetTextColor(hDC, RGB(0,0,0));
    TextOut(hDC, 32, 13,"T", 1);

    // determine window dimensions & set up fan text parameters
    GetClientRect(hwnd, &R);
    FontRec = MainFontRec;
    DeleteObject(SelectObject(hDC, CreateFontIndirect(&FontRec)));
    GetOutlineTextMetrics(hDC, sizeof(FontMetric), &FontMetric);
    FontHeight = FontMetric.otmTextMetrics.tmHeight;
    SetViewportOrg(hDC, FontHeight+2, 0);
    R.right -= FontHeight+2;
    BaseWidth = LOWORD(GetTextExtent(hDC, FanText, FanTextLen));

    // get a "black brush" for drawing operations
    SelectObject(hDC, GetStockObject(NULL_BRUSH));

    // if we want to show the alignment marks, draw the bounding ellipse
    if (ShowAlignmentMarks)
    {
        Ellipse(hDC, -R.right, -R.bottom, R.right, R.bottom);
    }

    // draw the "hub" of the fan
    Ellipse(hDC, -(Radius-5), -(Radius-5), (Radius-5), Radius-5);
    Ellipse(hDC, -(Radius-10), -(Radius-10), (Radius-10), Radius-10);

    SetTextColor(hDC, FanColor[0]);

    // loop over the "fan leaves"
    for ( d = 27; d <= 36; d++)
    {
        x = ROUND(Radius * cos(d * Deg2Rad));
        y = ROUND(Radius * sin(-d * Deg2Rad)); // -d because y axis is inverted

        Theta = -d * Deg2Rad;
        if (x)
        {
            Theta = atan((R.right / (R.bottom * 1.0)) * (y / (x * 1.0)));
        }

        j = ROUND(R.right * cos(Theta));
        k = ROUND(R.bottom * sin(Theta));

        if (ShowAlignmentMarks)
        {
            MoveTo(hDC, x,y);
            LineTo(hDC, j,k);
        }

        DesiredExtent = ROUND(sqrt(SQR(x*1.0 - j) + SQR(y*1.0 - k))) - 5;
        FontRec = MainFontRec;
        FontRec.lfEscapement = d * 100;
        FontRec.lfWidth = floor((FontMetric.otmTextMetrics.tmAveCharWidth) *
                                (DesiredExtent / (BaseWidth * 1.0)));
        DeleteObject(SelectObject(hDC, CreateFontIndirect(&FontRec)));
        TE = GetTextExtent(hDC, FanText, FanTextLen);

        for ( ;(LOWORD(TE) > DesiredExtent) && (FontRec.lfWidth);
             FontRec.lfWidth-- )
        {
            // Shave off some character width until the string fits 
            DeleteObject(SelectObject(hDC, CreateFontIndirect(&FontRec)));
            TE = GetTextExtent(hDC, FanText, FanTextLen);
        }

        // Expand the string if necessary to make it fit the desired extent 
        if (LOWORD(TE) < DesiredExtent)
          { SetTextJustification(hDC,DesiredExtent - LOWORD(TE), 3); }
        if (ShadowAll)
        {
            SetTextColor(hDC, RGB(0,0,0));
            TextOut(hDC, x+2, y+1, FanText, FanTextLen);
        }
        SetTextColor(hDC, FanColor[d - 27]);
        TextOut(hDC, x, y, FanText, FanTextLen);
        // clear justifier's internal error accumulator 
        SetTextJustification(hDC,0,0);

        if (P[0])
        {
            FontRec = CornerFontRec;
            FontRec.lfEscapement = (d+10) * 100;
            FontRec.lfWidth = 0;
            DeleteObject(SelectObject(hDC, CreateFontIndirect(&FontRec)));
            SetTextColor(hDC, 0);
            x = floor((Radius - FontHeight - 5) * cos(d * Deg2Rad));
            y = floor((Radius - FontHeight - 5) * sin(-d * Deg2Rad));
            TextOut(hDC, x, y, P, 1);
            P++;
        } // if
    } // for d

    // lose the fan font, selecting in the Borland text font
    DeleteObject(SelectObject(hDC, CreateFontIndirect(&BorlandFontRec)));
    TE = GetTextExtent(hDC, BorlandText, strlen(BorlandText));
    SetTextColor(hDC, RGB(0,0,0));
    // write the Borland text in the lower right corner, with a shadow effect
    TextOut(hDC, R.right - LOWORD(TE), R.bottom - HIWORD(TE), BorlandText,
            strlen(BorlandText));
    SetTextColor(hDC, RGB(255,0,0));
    TextOut(hDC, R.right - LOWORD(TE) - 5, R.bottom - HIWORD(TE), BorlandText,
            strlen(BorlandText));

    DeleteObject(SelectObject(hDC, GetStockObject(SYSTEM_FONT)));
    // restore the saved DC; easiest way to reset to entry state
    RestoreDC(hDC, -1);
    EndPaint(hwnd, &PaintInfo);
} // end of DoPaint()