Changeset 11276


Ignore:
Timestamp:
Aug 24, 1999, 5:57:27 PM (26 years ago)
Author:
cbratschi
Message:

rectangle functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified tags/trunk/src/user32/new/user32.cpp

    r11193 r11276  
    1 /* $Id: user32.cpp,v 1.14 1999-08-19 12:53:56 sandervl Exp $ */
     1/* $Id: user32.cpp,v 1.15 1999-08-24 15:57:27 cbratschi Exp $ */
    22
    33/*
     
    7777// WIN32API YieldTask
    7878
    79 //Coordinate transformation
     79/* Coordinate Transformation */
    8080
    8181inline void OS2ToWin32ScreenPos(POINT *dest,POINT *source)
     
    9090}
    9191
    92 //******************************************************************************
    93 //******************************************************************************
     92/* Rectangle Functions - parts from wine/windows/rect.c */
     93
     94BOOL WIN32API CopyRect( PRECT lprcDst, const RECT * lprcSrc)
     95{
     96//    ddprintf(("USER32:  CopyRect\n"));
     97    if (!lprcDst || !lprcSrc) {
     98        SetLastError(ERROR_INVALID_PARAMETER);
     99        return FALSE;
     100    }
     101
     102    memcpy(lprcDst,lprcSrc,sizeof(RECT));
     103
     104    return TRUE;
     105}
     106//******************************************************************************
     107//******************************************************************************
     108BOOL WIN32API EqualRect( const RECT *lprc1, const RECT *lprc2)
     109{
     110#ifdef DEBUG
     111    WriteLog("USER32:  EqualRect\n");
     112#endif
     113    if (!lprc1 || !lprc2)
     114    {
     115      SetLastError(ERROR_INVALID_PARAMETER);
     116      return FALSE;
     117    }
     118
     119    return (lprc1->left == lprc2->left &&
     120            lprc1->right == lprc2->right &&
     121            lprc1->top == lprc2->top &&
     122            lprc1->bottom == lprc2->bottom);
     123}
     124//******************************************************************************
     125//******************************************************************************
     126BOOL WIN32API InflateRect( PRECT lprc, int dx, int  dy)
     127{
     128#ifdef DEBUG
     129    WriteLog("USER32:  InflateRect\n");
     130#endif
     131    if (!lprc)
     132    {
     133      SetLastError(ERROR_INVALID_PARAMETER);
     134      return FALSE;
     135    }
     136
     137    lprc->left   -= dx;
     138    lprc->right  += dx;
     139    lprc->top    -= dy;
     140    lprc->bottom += dy;
     141
     142    return TRUE;
     143}
     144//******************************************************************************
     145//******************************************************************************
     146BOOL WIN32API IntersectRect( PRECT lprcDst, const RECT * lprcSrc1, const RECT * lprcSrc2)
     147{
     148#ifdef DEBUG
     149////    WriteLog("USER32:  IntersectRect\n");
     150#endif
     151    if (!lprcDst || !lprcSrc1 || !lprcSrc2)
     152    {
     153      SetLastError(ERROR_INVALID_PARAMETER);
     154      return FALSE;
     155    }
     156
     157    if (IsRectEmpty(lprcSrc1) || IsRectEmpty(lprcSrc2) ||
     158       (lprcSrc1->left >= lprcSrc2->right) || (lprcSrc2->left >= lprcSrc1->right) ||
     159       (lprcSrc1->top >= lprcSrc2->bottom) || (lprcSrc2->top >= lprcSrc1->bottom))
     160    {
     161      SetLastError(ERROR_INVALID_PARAMETER);
     162      SetRectEmpty(lprcDst);
     163      return FALSE;
     164    }
     165    lprcDst->left   = MAX(lprcSrc1->left,lprcSrc2->left);
     166    lprcDst->right  = MIN(lprcSrc1->right,lprcSrc2->right);
     167    lprcDst->top    = MAX(lprcSrc1->top,lprcSrc2->top);
     168    lprcDst->bottom = MIN(lprcSrc1->bottom,lprcSrc2->bottom);
     169
     170    return TRUE;
     171}
     172//******************************************************************************
     173//******************************************************************************
     174BOOL WIN32API IsRectEmpty( const RECT * lprc)
     175{
     176#ifdef DEBUG
     177    WriteLog("USER32:  IsRectEmpty\n");
     178#endif
     179    if (!lprc)
     180    {
     181      SetLastError(ERROR_INVALID_PARAMETER);
     182      return FALSE;
     183    }
     184
     185    return (lprc->left == lprc->right || lprc->top == lprc->bottom);
     186}
     187//******************************************************************************
     188//******************************************************************************
     189BOOL WIN32API OffsetRect( PRECT lprc, int x, int  y)
     190{
     191#ifdef DEBUG
     192////    WriteLog("USER32:  OffsetRect\n");
     193#endif
     194    if (!lprc)
     195    {
     196      SetLastError(ERROR_INVALID_PARAMETER);
     197      return FALSE;
     198    }
     199
     200    lprc->left   += x;
     201    lprc->right  += x;
     202    lprc->top    += y;
     203    lprc->bottom += y;
     204
     205    return TRUE;
     206}
     207//******************************************************************************
     208//******************************************************************************
     209BOOL WIN32API PtInRect( const RECT *lprc, POINT pt)
     210{
     211#ifdef DEBUG1
     212    WriteLog("USER32:  PtInRect\n");
     213#endif
     214    if (!lprc)
     215    {
     216      SetLastError(ERROR_INVALID_PARAMETER);
     217      return FALSE;
     218    }
     219
     220    return (pt.x >= lprc->left &&
     221            pt.x < lprc->right &&
     222            pt.y >= lprc->top &&
     223            pt.y < lprc->bottom);
     224}
     225//******************************************************************************
     226//******************************************************************************
     227BOOL WIN32API SetRect( PRECT lprc, int nLeft, int nTop, int nRight, int  nBottom)
     228{
     229    if (!lprc)
     230    {
     231      SetLastError(ERROR_INVALID_PARAMETER);
     232      return FALSE;
     233    }
     234
     235    lprc->left   = nLeft;
     236    lprc->top    = nTop;
     237    lprc->right  = nRight;
     238    lprc->bottom = nBottom;
     239
     240    return TRUE;
     241}
     242//******************************************************************************
     243//******************************************************************************
     244BOOL WIN32API SetRectEmpty( PRECT lprc)
     245{
     246#ifdef DEBUG
     247    WriteLog("USER32:  SetRectEmpty\n");
     248#endif
     249    if (!lprc)
     250    {
     251      SetLastError(ERROR_INVALID_PARAMETER);
     252      return FALSE;
     253    }
     254
     255    lprc->left = lprc->right = lprc->top = lprc->bottom = 0;
     256
     257    return TRUE;
     258}
     259//******************************************************************************
     260//******************************************************************************
     261BOOL WIN32API SubtractRect( PRECT lprcDest, const RECT * lprcSrc1, const RECT * lprcSrc2)
     262{
     263#ifdef DEBUG
     264    WriteLog("USER32:  SubtractRect");
     265#endif
     266    RECT tmp;
     267
     268    if (!lprcDest || !lprcSrc1 || !lprcSrc2)
     269    {
     270      SetLastError(ERROR_INVALID_PARAMETER);
     271      return FALSE;
     272    }
     273
     274    if (IsRectEmpty(lprcSrc1))
     275    {
     276      SetLastError(ERROR_INVALID_PARAMETER);
     277      SetRectEmpty(lprcDest);
     278      return FALSE;
     279    }
     280    *lprcDest = *lprcSrc1;
     281    if (IntersectRect(&tmp,lprcSrc1,lprcSrc2))
     282    {
     283      if (EqualRect(&tmp,lprcDest))
     284      {
     285        SetRectEmpty(lprcDest);
     286        return FALSE;
     287      }
     288      if ((tmp.top == lprcDest->top) && (tmp.bottom == lprcDest->bottom))
     289      {
     290        if (tmp.left == lprcDest->left) lprcDest->left = tmp.right;
     291        else if (tmp.right == lprcDest->right) lprcDest->right = tmp.left;
     292      }
     293      else if ((tmp.left == lprcDest->left) && (tmp.right == lprcDest->right))
     294      {
     295        if (tmp.top == lprcDest->top) lprcDest->top = tmp.bottom;
     296        else if (tmp.bottom == lprcDest->bottom) lprcDest->bottom = tmp.top;
     297      }
     298    }
     299
     300    return TRUE;
     301}
     302//******************************************************************************
     303//******************************************************************************
     304BOOL WIN32API UnionRect( PRECT lprcDst, const RECT *lprcSrc1, const RECT *lprcSrc2)
     305{
     306#ifdef DEBUG
     307    WriteLog("USER32:  UnionRect\n");
     308#endif
     309    if (!lprcDst || !lprcSrc1 || !lprcSrc2)
     310    {
     311      SetLastError(ERROR_INVALID_PARAMETER);
     312      return FALSE;
     313    }
     314
     315    if (IsRectEmpty(lprcSrc1))
     316    {
     317      if (IsRectEmpty(lprcSrc2))
     318      {
     319        SetLastError(ERROR_INVALID_PARAMETER);
     320        SetRectEmpty(lprcDst);
     321        return FALSE;
     322      }
     323      else *lprcDst = *lprcSrc2;
     324    }
     325    else
     326    {
     327      if (IsRectEmpty(lprcSrc2)) *lprcDst = *lprcSrc1;
     328      else
     329      {
     330        lprcDst->left   = MIN(lprcSrc1->left,lprcSrc2->left);
     331        lprcDst->right  = MAX(lprcSrc1->right,lprcSrc2->right);
     332        lprcDst->top    = MIN(lprcSrc1->top,lprcSrc2->top);
     333        lprcDst->bottom = MAX(lprcSrc1->bottom,lprcSrc2->bottom);       
     334      }
     335    }
     336
     337    return TRUE;
     338}
     339
     340/* String Manipulating Functions */
     341
    94342int __cdecl wsprintfA(char *lpOut, LPCSTR lpFmt, ...)
    95343{
     
    235483//******************************************************************************
    236484//******************************************************************************
    237 
    238 //******************************************************************************
    239 //******************************************************************************
    240 BOOL WIN32API OffsetRect( PRECT lprc, int x, int  y)
    241 {
    242 #ifdef DEBUG
    243 ////    WriteLog("USER32:  OffsetRect\n");
    244 #endif
    245     if (lprc)
    246     {
    247       lprc->left   += x;
    248       lprc->right  += x;
    249       lprc->top    += y;
    250       lprc->bottom += y;
    251 
    252       return TRUE;
    253     } else return FALSE;
    254 }
    255 //******************************************************************************
    256 //******************************************************************************
    257 BOOL WIN32API CopyRect( PRECT lprcDst, const RECT * lprcSrc)
    258 {
    259 //    ddprintf(("USER32:  CopyRect\n"));
    260     if (!lprcDst || !lprcSrc) {
    261         SetLastError(ERROR_INVALID_PARAMETER);
    262         return FALSE;
    263     }
    264 
    265     memcpy(lprcDst,lprcSrc,sizeof(RECT));
    266 
    267     return TRUE;
    268 }
    269 //******************************************************************************
    270 //******************************************************************************
    271485int WIN32API GetSystemMetrics(int nIndex)
    272486{
     
    407621//******************************************************************************
    408622//******************************************************************************
    409 BOOL WIN32API InflateRect( PRECT lprc, int dx, int  dy)
    410 {
    411 #ifdef DEBUG
    412     WriteLog("USER32:  InflateRect\n");
    413 #endif
    414     if (!lprc) return FALSE;
    415     //right?
    416     lprc->left   -= dx;
    417     lprc->right  += dx;
    418     lprc->top    -= dy;
    419     lprc->bottom += dy;
    420 
    421     return TRUE;
    422 }
    423623//******************************************************************************
    424624//TODO:How can we emulate this one in OS/2???
     
    447647//******************************************************************************
    448648//******************************************************************************
    449 BOOL WIN32API SetRect( PRECT lprc, int nLeft, int nTop, int nRight, int  nBottom)
    450 {
    451     if (!lprc) return FALSE;
    452     lprc->left   = nLeft;
    453     lprc->top    = nTop;
    454     lprc->right  = nRight;
    455     lprc->bottom = nBottom;
    456 
    457     return TRUE;
    458 }
    459 //******************************************************************************
    460 //******************************************************************************
    461649BOOL WIN32API WinHelpA( HWND hwnd, LPCSTR lpszHelp, UINT uCommand, DWORD  dwData)
    462650{
     
    468656
    469657    return(TRUE);
    470 }
    471 //******************************************************************************
    472 //******************************************************************************
    473 BOOL WIN32API SubtractRect( PRECT lprcDest, const RECT * lprcSrc1, const RECT * lprcSrc2)
    474 {
    475 #ifdef DEBUG
    476     WriteLog("USER32:  SubtractRect");
    477 #endif
    478     //CB: how?
    479     return O32_SubtractRect(lprcDest,lprcSrc1,lprcSrc2);
    480658}
    481659//******************************************************************************
     
    688866//******************************************************************************
    689867//******************************************************************************
    690 BOOL WIN32API EqualRect( const RECT * arg1, const RECT *  arg2)
    691 {
    692 #ifdef DEBUG
    693     WriteLog("USER32:  EqualRect\n");
    694 #endif
    695     return O32_EqualRect(arg1, arg2);
    696 }
    697 //******************************************************************************
    698 //******************************************************************************
    699868BOOL WIN32API ExcludeUpdateRgn( HDC arg1, HWND  arg2)
    700869{
     
    9061075//******************************************************************************
    9071076//******************************************************************************
    908 BOOL WIN32API IntersectRect( PRECT arg1, const RECT *  arg2, const RECT *  arg3)
    909 {
    910 #ifdef DEBUG
    911 ////    WriteLog("USER32:  IntersectRect\n");
    912 #endif
    913     return O32_IntersectRect(arg1, arg2, arg3);
    914 }
    915 //******************************************************************************
    916 //******************************************************************************
    9171077BOOL WIN32API InvalidateRgn( HWND arg1, HRGN arg2, BOOL  arg3)
    9181078{
     
    9301090#endif
    9311091    return O32_InvertRect(arg1, arg2);
    932 }
    933 //******************************************************************************
    934 //******************************************************************************
    935 BOOL WIN32API IsRectEmpty( const RECT * arg1)
    936 {
    937 #ifdef DEBUG
    938     WriteLog("USER32:  IsRectEmpty\n");
    939 #endif
    940     return O32_IsRectEmpty(arg1);
    9411092}
    9421093//******************************************************************************
     
    9791130//******************************************************************************
    9801131//******************************************************************************
    981 BOOL WIN32API PtInRect( const RECT * arg1, POINT  arg2)
    982 {
    983 #ifdef DEBUG1
    984     WriteLog("USER32:  PtInRect\n");
    985 #endif
    986     return O32_PtInRect(arg1, arg2);
    987 }
    988 //******************************************************************************
    989 //******************************************************************************
    9901132BOOL WIN32API ScreenToClient( HWND arg1, LPPOINT  arg2)
    9911133{
     
    10281170#endif
    10291171    return O32_SetDoubleClickTime(arg1);
    1030 }
    1031 //******************************************************************************
    1032 //******************************************************************************
    1033 BOOL WIN32API SetRectEmpty( PRECT arg1)
    1034 {
    1035 #ifdef DEBUG
    1036     WriteLog("USER32:  SetRectEmpty\n");
    1037 #endif
    1038     return O32_SetRectEmpty(arg1);
    10391172}
    10401173//******************************************************************************
     
    11971330//******************************************************************************
    11981331//******************************************************************************
    1199 BOOL WIN32API UnionRect( PRECT arg1, const RECT * arg2, const RECT *  arg3)
    1200 {
    1201 #ifdef DEBUG
    1202     WriteLog("USER32:  UnionRect\n");
    1203 #endif
    1204     return O32_UnionRect(arg1, arg2, arg3);
    1205 }
    1206 //******************************************************************************
    1207 //******************************************************************************
    12081332BOOL WIN32API ValidateRect( HWND arg1, const RECT * arg2)
    12091333{
Note: See TracChangeset for help on using the changeset viewer.