示例#1
0
文件: window.cpp 项目: drodin/Crimson
void Window::DrawBack( const Rect &rect ) {
  const static Image bg( view->GetSystemIcons(), 0, 34, 30, 30 );
  Rect clip;
  FillPattern( rect, bg, 0, 0 );
  GetClipRect( clip );
  SetClipRect( rect );
  DrawBox( Rect(0, 0, w, h), BOX_RAISED );
  SetClipRect( clip );
}
示例#2
0
// ****************************************************************************
//
//  Function Name:	RGpDrawingSurface::IntersectClipRect( )
//
//  Description:		Sets a new clip rect that is the interesection of the
//							current clip rect and the given clip rect
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RGpDrawingSurface::IntersectClipRect( const RIntRect& newRect )
{
    RIntRect		clipRect = GetClipRect();

    clipRect.Intersect( clipRect, newRect );
    SetClipRect( clipRect );
}
示例#3
0
ECode CTransformation::SetClipRect(
    /* [in] */ IRect* r)
{
    Int32 left = 0, top = 0, right = 0, bottom = 0;
    r->Get(&left, &top, &right, &bottom);
    return SetClipRect(left, top, right, bottom);
}
示例#4
0
bool csGraphics2D::Open ()
{
  if (is_open) return true;
  is_open = true;

  vpLeft = 0;
  vpTop = 0;
  
  FrameBufferLocked = 0;

  SetClipRect (0, 0, fbWidth, fbHeight);
  
  if (!FullScreen && fitToWorkingArea)
  {
    int newWidth (vpWidth), newHeight (vpHeight);
    if (FitSizeToWorkingArea (newWidth, newHeight))
    {
      bool oldResize (AllowResizing);
      AllowResizing = true;
      Resize (newWidth, newHeight);
      AllowResizing = oldResize;
    }
  }

  return true;
}
示例#5
0
RSBmFont::RSBmFont(RealSpace *pRS)
{
	SetClipRect(0,0,640,480);

	m_pKorFnt	= NULL;
	m_pEngFnt	= NULL;
	m_pRS		= pRS;		// 절대 pRS가 NULL이면 안된다.
}
示例#6
0
// ****************************************************************************
//
//  Function Name:	RGpDrawingSurface::IntersectClipVectorRect( )
//
//  Description:		Sets a new clip rect that is the interesection of the
//							current clip rect and the given clip vector rect
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RGpDrawingSurface::IntersectClipVectorRect( const RIntVectorRect& vectRect )
{
    RIntRect		clipRect = GetClipRect();
    RIntRect		newRect = vectRect.m_TransformedBoundingRect;

    clipRect.Intersect( clipRect, newRect );
    SetClipRect( clipRect );
}
示例#7
0
void CPWL_Label::OnCreated() {
  SetParamByFlag();
  SetFontSize(GetCreationParam().fFontSize);

  m_pEdit->SetFontMap(GetFontMap());
  m_pEdit->Initialize();

  if (HasFlag(PES_TEXTOVERFLOW)) {
    SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f));
    m_pEdit->SetTextOverflow(TRUE);
  }
}
TBRect TBRendererBatcher::SetClipRect(const TBRect &rect, bool add_to_current)
{
	TBRect old_clip_rect = m_clip_rect;
	m_clip_rect = rect;
	m_clip_rect.x += m_translation_x;
	m_clip_rect.y += m_translation_y;

	if (add_to_current)
		m_clip_rect = m_clip_rect.Clip(old_clip_rect);

	FlushAllInternal();
	SetClipRect(m_clip_rect);

	old_clip_rect.x -= m_translation_x;
	old_clip_rect.y -= m_translation_y;
	return old_clip_rect;
}
void MythQImagePainter::Begin(QPaintDevice *parent)
{
    if (!parent)
    {
        VERBOSE(VB_IMPORTANT, "FATAL ERROR: No parent widget defined for "
                              "QT Painter, bailing");
        return;
    }

    MythPainter::Begin(parent);
    painter       = new QPainter(parent);
    copy          = true;
    paintedRegion = QRegion();
    painter->setCompositionMode(QPainter::CompositionMode_Source);
    clipRegion = QRegion();
    SetClipRect(QRect());
}
示例#10
0
ECode CTransformation::Compose(
    /* [in] */ ITransformation* t)
{
    Float alpha;
    t->GetAlpha(&alpha);
    mAlpha *= alpha;

    AutoPtr<IMatrix> matrix;
    t->GetMatrix((IMatrix**)&matrix);
    Boolean res;
    mMatrix->PreConcat(matrix, &res);
    if (((CTransformation*)t)->mHasClipRect) {
        AutoPtr<IRect> cr;
        t->GetClipRect((IRect**)&cr);
        SetClipRect(cr);
    }
    return NOERROR;
}
示例#11
0
bool CMouseMgr::Init(int xPosInit, int yPosInit,
                     int xMin, int yMin,
                     int xMax, int yMax
                    )
{
    m_xPos = xPosInit;
    m_yPos = yPosInit;
    m_xPrev = m_xPos;
    m_yPrev = m_yPos;

    m_xMin = xMin;
    m_xMax = xMax;
    m_yMin = yMin;
    m_yMax = yMax;

    m_bDefault = false;
    SetClipRect(NULL);

    return true;
}
示例#12
0
ECode CTransformation::Set(
    /* [in] */ ITransformation* t)
{
    t->GetAlpha(&mAlpha);
    AutoPtr<IMatrix> matrix;
    t->GetMatrix((IMatrix**)&matrix);
    mMatrix->Set(matrix);
    if (((CTransformation*)t)->mHasClipRect) {
        AutoPtr<IRect> cr;
        t->GetClipRect((IRect**)&cr);
        SetClipRect(cr);
    }
    else {
        mHasClipRect = FALSE;
        mClipRect->SetEmpty();
    }
    t->GetTransformationType(&mTransformationType);

    return NOERROR;
}
示例#13
0
ECode CTransformation::PostCompose(
    /* [in] */ ITransformation* t)
{
    assert(t != NULL);
    Float a = 0.f;
    t->GetAlpha(&a);

    mAlpha *= a;
    AutoPtr<IMatrix> mx;
    t->GetMatrix((IMatrix**)&mx);
    Boolean result;
    mMatrix->PostConcat(mx, &result);

    if (((CTransformation*)t)->mHasClipRect) {
        AutoPtr<IRect> cr;
        t->GetClipRect((IRect**)&cr);
        SetClipRect(cr);
    }
    return NOERROR;
}
示例#14
0
void CPWL_Edit::SetParamByFlag() {
  if (HasFlag(PES_RIGHT)) {
    m_pEdit->SetAlignmentH(2, FALSE);
  } else if (HasFlag(PES_MIDDLE)) {
    m_pEdit->SetAlignmentH(1, FALSE);
  } else {
    m_pEdit->SetAlignmentH(0, FALSE);
  }

  if (HasFlag(PES_BOTTOM)) {
    m_pEdit->SetAlignmentV(2, FALSE);
  } else if (HasFlag(PES_CENTER)) {
    m_pEdit->SetAlignmentV(1, FALSE);
  } else {
    m_pEdit->SetAlignmentV(0, FALSE);
  }

  if (HasFlag(PES_PASSWORD)) {
    m_pEdit->SetPasswordChar('*', FALSE);
  }

  m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE);
  m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE);
  m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE);
  m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE);
  m_pEdit->EnableUndo(HasFlag(PES_UNDO));

  if (HasFlag(PES_TEXTOVERFLOW)) {
    SetClipRect(CPDF_Rect(0.0f, 0.0f, 0.0f, 0.0f));
    m_pEdit->SetTextOverflow(TRUE, FALSE);
  } else {
    if (m_pEditCaret) {
      m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(
          GetClientRect(), 1.0f));  //+1 for caret beside border
    }
  }

  if (HasFlag(PES_SPELLCHECK)) {
    m_pSpellCheck = GetCreationParam().pSpellCheck;
  }
}
示例#15
0
void CPWL_NoteItem::RePosChildWnd()
{
	if (this->IsValid())
	{
		ASSERT(m_pSubject != NULL);
		ASSERT(m_pDateTime != NULL);
		ASSERT(m_pContents != NULL);

		CPDF_Rect rcClient = GetClientRect();

		CPDF_Rect rcSubject = rcClient;
		rcSubject.left += POPUP_ITEM_TEXT_INDENT;
		rcSubject.top = rcClient.top;
		rcSubject.right = PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f, rcClient.right);
		rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height();
		rcSubject.Normalize();
		m_pSubject->Move(rcSubject, TRUE, FALSE);
		m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject));

		CPDF_Rect rcDate = rcClient;
		rcDate.right -= POPUP_ITEM_TEXT_INDENT;
		rcDate.left = PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f, rcSubject.right);
		rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height();
		rcDate.Normalize();
		m_pDateTime->Move(rcDate, TRUE, FALSE);
		m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate));

		CPDF_Rect rcContents = rcClient;
		rcContents.left += 1.0f;
		rcContents.right -= 1.0f;
		rcContents.top = rcDate.bottom - POPUP_ITEM_HEAD_BOTTOM;
		rcContents.bottom += POPUP_ITEM_BOTTOMWIDTH;
		rcContents.Normalize();
		m_pContents->Move(rcContents, TRUE, FALSE);
		m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents));
	}

	SetClipRect(CPWL_Utils::InflateRect(GetWindowRect(),1.0f));
}
示例#16
0
void CPWL_Edit::SetParamByFlag() {
  if (HasFlag(PES_RIGHT)) {
    m_pEdit->SetAlignmentH(2, false);
  } else if (HasFlag(PES_MIDDLE)) {
    m_pEdit->SetAlignmentH(1, false);
  } else {
    m_pEdit->SetAlignmentH(0, false);
  }

  if (HasFlag(PES_BOTTOM)) {
    m_pEdit->SetAlignmentV(2, false);
  } else if (HasFlag(PES_CENTER)) {
    m_pEdit->SetAlignmentV(1, false);
  } else {
    m_pEdit->SetAlignmentV(0, false);
  }

  if (HasFlag(PES_PASSWORD)) {
    m_pEdit->SetPasswordChar('*', false);
  }

  m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), false);
  m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), false);
  m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), false);
  m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), false);
  m_pEdit->EnableUndo(HasFlag(PES_UNDO));

  if (HasFlag(PES_TEXTOVERFLOW)) {
    SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f));
    m_pEdit->SetTextOverflow(true, false);
  } else {
    if (m_pEditCaret) {
      m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(
          GetClientRect(), 1.0f));  // +1 for caret beside border
    }
  }
}
示例#17
0
/*
 * DrawAreaWinProc - window procedure for the drawing area window
 *                 - this window is an MDI window
 */
MRESULT CALLBACK DrawAreaWinProc( HWND hwnd, WPI_MSG msg,
                                  WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    static WPI_POINT    start_pt = { -1, -1 };
    static WPI_POINT    end_pt = { -1, -1 };
    static WPI_POINT    prev_pt = { -1, -1 };
    static WPI_POINT    new_pt = { -1, -1 };
    static WPI_POINT    pt1;
    static BOOL         flbuttondown = FALSE;
    static BOOL         frbuttondown = FALSE;
    static BOOL         fdraw_shape = FALSE;
    static BOOL         firsttime;
    static BOOL         wasicon;
    int                 mousebutton;
    WPI_POINT           pointsize;
    WPI_POINT           pt2;
#ifndef __OS2_PM__
    CREATESTRUCT        *cs;
    MDICREATESTRUCT     *mdi_cs;
    MINMAXINFO          *minmax;
#endif
    img_node            *node;
    int                 i;

    switch ( msg ) {
    case WM_CREATE:
#ifndef __OS2_PM__
        cs = (CREATESTRUCT __FAR *)lparam;
        mdi_cs = (MDICREATESTRUCT __FAR *)cs->lpCreateParams;
        node = (img_node *)mdi_cs->lParam;

        for( i = 0; i < node->num_of_images; i++ ) {
            node[i].hwnd = hwnd;
        }
        AddImageNode( node );
        CreateUndoStack( node );
        setTheCursor( -1, hwnd );
        wasicon = FALSE;
#endif
        firsttime = TRUE;
        i = i;
        return( 0 );

    case WM_MDIACTIVATE:
        if( IMGED_GET_MDI_FACTIVATE( hwnd, wparam, lparam ) ) {
            if( _wpi_isiconic( hwnd ) ) {
                wasicon = TRUE;
                break;
            } else {
                wasicon = FALSE;
                FocusOnImage( hwnd );
            }
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_GETMINMAXINFO:
        node = SelectImage( hwnd );
        if( node != NULL ) {
            minmax = (MINMAXINFO *)lparam;
            minmax->ptMinTrackSize.x = node->width +
                2 * _wpi_getsystemmetrics( SM_CXFRAME );
            minmax->ptMinTrackSize.y = node->height +
                2 * _wpi_getsystemmetrics( SM_CYFRAME ) +
                _wpi_getsystemmetrics( SM_CYCAPTION ) - 1;
        }
        break;
#endif

    case UM_SHOWVIEWWINDOW:
        ShowViewWindows( hwnd );
        return 0;

    case WM_SIZE:
        if ( _imgwpi_issizerestored( wparam ) ) {
            ResizeChild( lparam, hwnd, firsttime );
            firsttime = FALSE;
            if( wasicon ) {
                FocusOnImage( hwnd );
                wasicon = FALSE;
            }
#ifndef __OS2_PM__
        } else if ( _imgwpi_issizeminimized( wparam ) ) {
            node = SelectImage( hwnd );
            HideViewWindow( hwnd );
            DeleteActiveImage();
            ClearImageText();
            SendMessage( ClientWindow, WM_MDINEXT, (WPARAM)(LPVOID)hwnd, 0L );
            wasicon = TRUE;
#endif
        }
        return( 0 );

#ifndef __OS2_PM__
    case WM_CHAR:
        pointsize = GetPointSize( hwnd );
        if( LOWORD( wparam ) == ESC_CHAR ) {
            if( !(lparam & 0x40000000) ) {
                switch( toolType ) {
                case IMGED_PASTE:
                    fdraw_shape = FALSE;
                    flbuttondown = FALSE;
                    frbuttondown = FALSE;
                    DontPaste( hwnd, &pt1, pointsize );
                    break;

                case IMGED_LINE:
                case IMGED_RECTO:
                case IMGED_RECTF:
                case IMGED_CIRCLEO:
                case IMGED_CIRCLEF:
                case IMGED_CLIP:
                    if( !flbuttondown && !frbuttondown ) {
                        break;
                    }
                    fdraw_shape = FALSE;
                    flbuttondown = FALSE;
                    frbuttondown = FALSE;
                    if( toolType == IMGED_LINE ) {
                        OutlineLine( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                    } else if( toolType == IMGED_CLIP ) {
                        OutlineClip( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                        SetRectExists( FALSE );
                    } else {
                        OutlineRegion( hwnd, &start_pt, &prev_pt, &new_pt, TRUE );
                    }
                    break;
                default:
                    break;
                }
            }
        }
        return( 0 );
#endif

    case WM_MOUSEMOVE:
        pointsize = GetPointSize( hwnd );
#ifdef __OS2_PM__
        WinSetPointer( HWND_DESKTOP, hCursor[cursorIndex] );
#endif
        IMGED_MAKEPOINT( wparam, lparam, new_pt );

        switch( toolType ) {
        case IMGED_SNAP:
#ifndef __OS2_PM__
            OutlineSnap();
#endif
            break;

        case IMGED_PASTE:
            pt1.x = new_pt.x / pointsize.x;
            pt1.y = new_pt.y / pointsize.y;
            pt2.x = prev_pt.x / pointsize.x;
            pt2.y = prev_pt.y / pointsize.y;
            if( pt1.x != pt2.x || pt1.y != pt2.y ) {
                DragClipBitmap( hwnd, &pt1, pointsize );
            }
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        case IMGED_FREEHAND:
        case IMGED_BRUSH:
            if( flbuttondown ) {
                Paint( hwnd, &prev_pt, &new_pt, LMOUSEBUTTON );
            } else if( frbuttondown ) {
                Paint( hwnd, &prev_pt, &new_pt, RMOUSEBUTTON );
            }
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        case IMGED_LINE:
        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
        case IMGED_CLIP:
            if( flbuttondown || frbuttondown ) {
                if( new_pt.x / pointsize.x != end_pt.x / pointsize.x ||
                    new_pt.y / pointsize.y != end_pt.y / pointsize.y ) {
                    if( toolType == IMGED_LINE ) {
                        OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    } else if( toolType == IMGED_CLIP ) {
                        OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    } else {
                        OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, FALSE );
                    }
                    end_pt = new_pt;
                    SetSizeInStatus( hwnd, &start_pt, &new_pt, &pointsize );
                }
            } else {
                SetPosInStatus( &new_pt, &pointsize, hwnd );
            }
            break;

        case IMGED_FILL:
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;

        default:
            SetPosInStatus( &new_pt, &pointsize, hwnd );
            break;
        }
        prev_pt = new_pt;
        return( 0 );

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
        pointsize = GetPointSize( hwnd );
        SetCapture( hwnd );
        if( msg == WM_LBUTTONDOWN ) {
            if( frbuttondown ) {
                break;
            }
#ifdef __OS2_PM__
            node = GetCurrentNode();
            if( hwnd != node->hwnd ) {
                break;
            }
#endif
            flbuttondown = TRUE;
            mousebutton = LMOUSEBUTTON;
        } else {
            if( flbuttondown ) {
                break;
            }
            node = GetCurrentNode();
            if( hwnd != node->hwnd ) {
                break;
            }
            frbuttondown = TRUE;
            mousebutton = RMOUSEBUTTON;
        }
        fdraw_shape = TRUE;
        IMGED_MAKEPOINT( wparam, lparam, start_pt );
        IMGED_MAKEPOINT( wparam, lparam, new_pt );

        switch( toolType ) {
        case IMGED_SNAP:
#ifndef __OS2_PM__
            TransferImage( hwnd );
#endif
            fdraw_shape = FALSE;
            flbuttondown = FALSE;
            frbuttondown = FALSE;
            break;

        case IMGED_FREEHAND:
        case IMGED_BRUSH:
            BeginFreeHand( hwnd );
            DrawSinglePoint( hwnd, &start_pt, mousebutton );
            break;

        case IMGED_LINE:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            OutlineLine( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_RECTO:
        case IMGED_RECTF:
        case IMGED_CIRCLEO:
        case IMGED_CIRCLEF:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            OutlineRegion( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_CLIP:
            IMGED_MAKEPOINT( wparam, lparam, end_pt );
            RedrawPrevClip( hwnd );
            OutlineClip( hwnd, &start_pt, &new_pt, &prev_pt, TRUE );
            break;

        case IMGED_FILL:
            FillArea( &start_pt, mousebutton );
            RecordImage( hwnd );
            break;

        case IMGED_HOTSPOT:
            SetIsSaved( hwnd, FALSE );
            prev_pt.x = start_pt.x / pointsize.x;
            prev_pt.y = start_pt.y / pointsize.y;
            SetNewHotSpot( &prev_pt );
            break;

        default:
            break;
        }
        prev_pt = new_pt;
        return 0;

    case WM_LBUTTONUP:
    case WM_RBUTTONUP:
        pointsize = GetPointSize( hwnd );
        IMGED_MAKEPOINT( wparam, lparam, end_pt );
        IMGED_MAKEPOINT( wparam, lparam, new_pt );
        if( msg == WM_LBUTTONUP ) {
            mousebutton = LMOUSEBUTTON;
        } else {
            mousebutton = RMOUSEBUTTON;
        }

        if( fdraw_shape ) {
            switch( toolType ) {
            case IMGED_PASTE:
                PasteImage( &start_pt, pointsize, hwnd );
                flbuttondown = FALSE;
                frbuttondown = FALSE;
                break;

            case IMGED_FREEHAND:
            case IMGED_BRUSH:
                if( flbuttondown || frbuttondown ) {
                    EndFreeHand( hwnd );
                    RecordImage( hwnd );
                }
                break;

            case IMGED_LINE:
                DrawLine( hwnd, &start_pt, &end_pt, mousebutton );
                RecordImage( hwnd );
                break;

            case IMGED_RECTO:
            case IMGED_RECTF:
            case IMGED_CIRCLEO:
            case IMGED_CIRCLEF:
                DisplayRegion( hwnd, &start_pt, &end_pt, mousebutton );
                RecordImage( hwnd );
                break;

            case IMGED_CLIP:
                SetClipRect( hwnd, &start_pt, &end_pt, pointsize );
                break;

            default:
                break;
            }
            fdraw_shape = FALSE;
        }
        ReleaseCapture();
        flbuttondown = FALSE;
        frbuttondown = FALSE;
        prev_pt = new_pt;
        return( 0 );

    case WM_PAINT:
        RepaintDrawArea( hwnd );
        return( 0 );

    case WM_QUERYENDSESSION:
    case WM_CLOSE:
        if( lastChanceSave( hwnd ) ) {
            CloseCurrentImage( hwnd );
            return( (MRESULT)1 );
        } else {
            return( (MRESULT)0 );
        }

#ifndef __OS2_PM__
    case WM_DESTROY:
        SetCursor( LoadCursor( NULL, IDC_ARROW ) );
        return( 0 );
#endif

    default:
        break;
    }
    return( _imgwpi_defMDIchildproc( hwnd, msg, wparam, lparam ) );

} /* DrawAreaWinProc */
示例#18
0
	//--------------------------------------------------------------------
	CRenderState::~CRenderState()
	{
		SetClipRect( NO_CLIPPING, NO_CLIPPING, NO_CLIPPING, NO_CLIPPING );
		SetTexName( NO_TEXTURE );
		glPopMatrix();
	}
示例#19
0
// ****************************************************************************
//
//  Function Name:	RGpDrawingSurface::SetClipVectorRect( )
//
//  Description:		Sets a new clip rect that is the interesection of the
//							current clip rect and the given clip vector rect
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RGpDrawingSurface::SetClipVectorRect( const RIntVectorRect& vectRect )
{
    SetClipRect( vectRect.m_TransformedBoundingRect );
}
示例#20
0
bool RSGDIFont::Create(const char *fontname,int nSize,bool bBold,bool bItalic,RSPIXELFORMAT pf,RSVIEWPORT *ClipRect)
{
	m_PixelFormat=pf;
	SetClipRect(ClipRect);

    HDC				hdc;
    LPBITMAPINFO	pbmi;

    m_hFont = CreateFont(nSize,
		0, 0, 0, bBold?FW_BOLD:FW_NORMAL, bItalic?TRUE:FALSE, FALSE, FALSE,
		DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS,
		DEFAULT_QUALITY,
		VARIABLE_PITCH,
		fontname);
    if (m_hFont == NULL)
        return FALSE;

    // Create a memory DC for rendering our text into
    hdc = GetDC(HWND_DESKTOP);
    m_hMemDC = CreateCompatibleDC(hdc);
    ReleaseDC(NULL, hdc);
    if (m_hMemDC == NULL)
    {
        DeleteObject(m_hFont);
        return FALSE;
    }

	SetMapMode(m_hMemDC,MM_TEXT);
    // Select font, and get text dimensions
    SelectObject(m_hMemDC, m_hFont);
    m_iBmpWidth = ClipRect->x2-ClipRect->x1 + 2;
    m_iBmpHeight = ClipRect->y2-ClipRect->y1 + 2;

    // Create a dib section for containing the bits
    pbmi = (LPBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFO) + PALETTE_SIZE * sizeof(RGBQUAD));
    if (pbmi == NULL)
    {
        DeleteObject(m_hFont);
        DeleteDC(m_hMemDC);
        return false;
    }

    pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    pbmi->bmiHeader.biWidth = m_iBmpWidth;
    pbmi->bmiHeader.biHeight = -1 * m_iBmpHeight;  // negative height = top-down
    pbmi->bmiHeader.biPlanes = 1;
    pbmi->bmiHeader.biBitCount = 8;  // 8bpp makes it easy to get data

    pbmi->bmiHeader.biCompression = BI_RGB;
    pbmi->bmiHeader.biXPelsPerMeter = 0;
    pbmi->bmiHeader.biYPelsPerMeter = 0;
    pbmi->bmiHeader.biClrUsed = PALETTE_SIZE;
    pbmi->bmiHeader.biClrImportant = PALETTE_SIZE;

    pbmi->bmiHeader.biSizeImage = WIDTHBYTES(m_iBmpWidth * 8) * m_iBmpHeight;

    // Just a plain monochrome palette
    pbmi->bmiColors[0].rgbRed = 0;
    pbmi->bmiColors[0].rgbGreen = 0;
    pbmi->bmiColors[0].rgbBlue = 0;
    pbmi->bmiColors[1].rgbRed = 255;
    pbmi->bmiColors[1].rgbGreen = 255;
    pbmi->bmiColors[1].rgbBlue = 255;

    // Create a DIB section that we can use to read the font bits out of
    m_hBitmap = CreateDIBSection(m_hMemDC,
                                 pbmi,
                                 DIB_RGB_COLORS,
                                 (void **) &m_pBmpBits,
                                 NULL,
                                 0);
    LocalFree(pbmi);
    if (m_hBitmap == NULL)
    {
        DeleteObject(m_hFont);
        DeleteDC(m_hMemDC);
        return false;
    }

    // Set up our memory DC with the font and bitmap
    SelectObject(m_hMemDC, m_hBitmap);
    SetBkColor(m_hMemDC, RGB(0, 0, 0));
    SetTextColor(m_hMemDC, RGB(255, 255, 255));
    return true;
}
示例#21
0
// ****************************************************************************
//
//  Function Name:	RGpDrawingSurface::RestoreDefaults()
//
//  Description:		Restores the default drawing surface attributes
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RGpDrawingSurface::RestoreDefaults()
{
    RDrawingSurface::RestoreDefaults( );
    // reset clip region
    SetClipRect( RIntRect( -16384, -16384, 16384, 16384 ) );
}