-/*
-** we use a window to represent plugin viewport,
-** whose geometry is limited by the clipping rectangle
-** all drawing within this window must follow must
-** follow coordinates system described in lprPosRect
-*/
-
-static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect)
-{
- RECT bounds;
- bounds.right = lprPosRect->right-lprPosRect->left;
-
- if( lprClipRect->left <= lprPosRect->left )
- {
- // left side is not clipped out
- bounds.left = 0;
-
- if( lprClipRect->right >= lprPosRect->right )
- {
- // right side is not clipped out, no change
- }
- else if( lprClipRect->right >= lprPosRect->left )
- {
- // right side is clipped out
- lprPosRect->right = lprClipRect->right;
- }
- else
- {
- // outside of clipping rectange, not visible
- lprPosRect->right = lprPosRect->left;
- }
- }
- else
- {
- // left side is clipped out
- bounds.left = lprPosRect->left-lprClipRect->left;
- bounds.right += bounds.left;
-
- lprPosRect->left = lprClipRect->left;
- if( lprClipRect->right >= lprPosRect->right )
- {
- // right side is not clipped out
- }
- else
- {
- // right side is clipped out
- lprPosRect->right = lprClipRect->right;
- }
- }
-
- bounds.bottom = lprPosRect->bottom-lprPosRect->top;
-
- if( lprClipRect->top <= lprPosRect->top )
- {
- // top side is not clipped out
- bounds.top = 0;
-
- if( lprClipRect->bottom >= lprPosRect->bottom )
- {
- // bottom side is not clipped out, no change
- }
- else if( lprClipRect->bottom >= lprPosRect->top )
- {
- // bottom side is clipped out
- lprPosRect->bottom = lprClipRect->bottom;
- }
- else
- {
- // outside of clipping rectange, not visible
- lprPosRect->right = lprPosRect->left;
- }
- }
- else
- {
- bounds.top = lprPosRect->top-lprClipRect->top;
- bounds.bottom += bounds.top;
-
- lprPosRect->top = lprClipRect->top;
- if( lprClipRect->bottom >= lprPosRect->bottom )
- {
- // bottom side is not clipped out
- }
- else
- {
- // bottom side is clipped out
- lprPosRect->bottom = lprClipRect->bottom;
- }
- }
- *lprClipRect = *lprPosRect;
- *lprPosRect = bounds;
-};
-