#include "basetype.h"#include "getypes.h"Go to the source code of this file.
Defines | |
| #define | GE_CLIP_CENTER 1 |
| #define | GE_CLIP_CORNER 0 |
Functions | |
| GENESISAPI geBoolean GENESISCC | CalculateClipping (GE_Rect *artRect, int32 *resultX, int32 *resultY, int32 x, int32 y, const GE_Rect bounds, int32 type) |
|
|
Definition at line 30 of file wgClip.H. Referenced by CalculateClipping(). |
|
|
Definition at line 31 of file wgClip.H. Referenced by geFont_DrawText(), and geFont_DrawTextToBitmap(). |
|
||||||||||||||||||||||||||||||||
|
Definition at line 41 of file wgClip.c. References GE_Rect::Bottom, GE_CLIP_CENTER, GE_FALSE, GE_TRUE, geBoolean, GENESISAPI, GENESISCC, int32, GE_Rect::Left, GE_Rect::Right, GE_Rect::Top, type, and y. Referenced by geFont_DrawText(), and geFont_DrawTextToBitmap().
00045 {
00046
00047 int32 localX, localY;
00048 int32 shiftX, shiftY;
00049 int32 baseX, baseY;
00050
00051 assert(artRect);
00052 assert(resultX);
00053 assert(resultY);
00054
00055 baseX = artRect->Left;
00056 baseY = artRect->Top;
00057
00058 // normalize the rect passed in.
00059 artRect->Left = artRect->Left - baseX;
00060 artRect->Right = artRect->Right - baseX;
00061 artRect->Top = artRect->Top - baseY;
00062 artRect->Bottom = artRect->Bottom - baseY;
00063
00064
00065 localX = x;
00066 localY = y;
00067
00068 if (GE_CLIP_CENTER == type)
00069 {
00070 shiftX = artRect->Right / 2;
00071 shiftY = artRect->Bottom / 2;
00072 }
00073 else
00074 {
00075 shiftX = 0;
00076 shiftY = 0;
00077 }
00078
00079 if (artRect->Right + localX - shiftX > bounds.Right)
00080 {
00081 artRect->Right -= (artRect->Right + localX - shiftX) - bounds.Right; // push Right edge Leftward
00082 }
00083
00084 if (artRect->Bottom + localY - shiftY > bounds.Bottom)
00085 {
00086 artRect->Bottom -= (artRect->Bottom + localY - shiftY) - bounds.Bottom; // push Bottom edge Leftward
00087 }
00088
00089 if (artRect->Left + localX - shiftX < bounds.Left)
00090 {
00091 localX += bounds.Left - (artRect->Left + localX - shiftX);
00092 artRect->Left += localX - x; // push Left edge Rightward
00093 }
00094
00095 if (artRect->Top + localY - shiftY < bounds.Top)
00096 {
00097 localY += bounds.Top - (artRect->Top + localY - shiftY);
00098 artRect->Top += localY - y;
00099 }
00100
00101 if (artRect->Left >= artRect->Right)
00102 return GE_FALSE;
00103 if (artRect->Top >= artRect->Bottom)
00104 return GE_FALSE;
00105
00106 *resultX = localX - shiftX;
00107 *resultY = localY - shiftY;
00108
00109 // un-normalize the rect passed in.
00110 artRect->Left = artRect->Left + baseX;
00111 artRect->Right = artRect->Right + baseX;
00112 artRect->Top = artRect->Top + baseY;
00113 artRect->Bottom = artRect->Bottom + baseY;
00114
00115
00116 return GE_TRUE;
00117 }
|
1.3.2