Ignore:
Timestamp:
Sep 15, 2001, 11:26:26 AM (24 years ago)
Author:
sandervl
Message:

restored old version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/tab.c

    r6705 r6709  
    3636  LPARAM lParam;
    3737  RECT   rect;    /* bounding rectangle of the item relative to the
    38            * leftmost item (the leftmost item, 0, would have a
    39            * "left" member of 0 in this rectangle)
    40                    *
     38                   * leftmost item (the leftmost item, 0, would have a
     39                   * "left" member of 0 in this rectangle)
     40                   * 
    4141                   * additionally the top member hold the row number
    4242                   * and bottom is unused and should be 0 */
     
    4949#endif
    5050  UINT       uNumItem;        /* number of tab items */
    51   UINT       uNumRows;        /* number of tab rows */
     51  UINT       uNumRows;        /* number of tab rows */
    5252  INT        tabHeight;       /* height of the tab row */
    5353  INT        tabWidth;        /* width of tabs */
     
    5757  HWND       hwndToolTip;     /* handle to tab's tooltip */
    5858  INT        leftmostVisible; /* Used for scrolling, this member contains
    59                    * the index of the first visible item */
     59                               * the index of the first visible item */
    6060  INT        iSelected;       /* the currently selected item */
    6161  INT        iHotTracked;     /* the highlighted item under the mouse */
     
    6363  TAB_ITEM*  items;           /* pointer to an array of TAB_ITEM's */
    6464  BOOL       DoRedraw;        /* flag for redrawing when tab contents is changed*/
    65   BOOL       needsScrolling;  /* TRUE if the size of the tabs is greater than
    66                    * the size of the control */
    67   BOOL       fSizeSet;        /* was the size of the tabs explicitly set? */
     65  BOOL       needsScrolling;  /* TRUE if the size of the tabs is greater than 
     66                               * the size of the control */
     67  BOOL       fSizeSet;        /* was the size of the tabs explicitly set? */
    6868  BOOL       bUnicode;        /* Unicode control? */
    6969  HWND       hwndUpDown;      /* Updown control used for scrolling */
     
    8181#define CONTROL_BORDER_SIZEX    2
    8282#define CONTROL_BORDER_SIZEY    2
    83 #define BUTTON_SPACINGX         4
     83#define BUTTON_SPACINGX         4 
    8484#define BUTTON_SPACINGY         4
    8585#define FLAT_BTN_SPACINGX       8
     
    137137{
    138138    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    139 
     139 
    140140    return infoPtr->iSelected;
    141141}
     
    145145{
    146146    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    147 
     147 
    148148    return infoPtr->uFocus;
    149149}
     
    164164  INT iItem = (INT)wParam;
    165165  INT prevItem;
    166 
     166 
    167167  prevItem = -1;
    168168  if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
     
    180180  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    181181  INT iItem=(INT) wParam;
    182 
     182 
    183183  if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0;
    184184
    185185  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
    186186    FIXME("Should set input focus\n");
    187   } else {
     187  } else { 
    188188    int oldFocus = infoPtr->uFocus;
    189189    if (infoPtr->iSelected != iItem || infoPtr->uFocus == -1 ) {
     
    232232  RECT tmpItemRect,clientRect;
    233233  LONG        lStyle  = GetWindowLongA(hwnd, GWL_STYLE);
    234 
     234 
    235235  /* Perform a sanity check and a trivial visibility check. */
    236236  if ( (infoPtr->uNumItem <= 0) ||
     
    245245  if (itemRect == NULL)
    246246    itemRect = &tmpItemRect;
    247 
     247 
    248248  /* Retrieve the unmodified item rect. */
    249249  *itemRect = infoPtr->items[itemIndex].rect;
     
    280280  else if(!(lStyle & TCS_VERTICAL) && !(lStyle & TCS_BOTTOM)) /* not TCS_BOTTOM and not TCS_VERTICAL */
    281281  {
    282     itemRect->bottom = clientRect.top +
     282    itemRect->bottom = clientRect.top + 
    283283                      infoPtr->tabHeight +
    284284                      itemRect->top * (infoPtr->tabHeight - 2) +
    285285                      ((lStyle & TCS_BUTTONS) ? itemRect->top * BUTTON_SPACINGY : 0);
    286     itemRect->top = clientRect.top +
     286    itemRect->top = clientRect.top + 
    287287                   SELECTED_TAB_OFFSET +
    288288                   itemRect->top * (infoPtr->tabHeight - 2) +
     
    291291
    292292  /*
    293    * "scroll" it to make sure the item at the very left of the
     293   * "scroll" it to make sure the item at the very left of the 
    294294   * tab control is the leftmost visible tab.
    295295   */
     
    297297  {
    298298    OffsetRect(itemRect,
    299          0,
    300          -(clientRect.bottom - infoPtr->items[infoPtr->leftmostVisible].rect.bottom));
     299             0,
     300             -(clientRect.bottom - infoPtr->items[infoPtr->leftmostVisible].rect.bottom));
    301301
    302302    /*
     
    305305     */
    306306    OffsetRect(itemRect,
    307          0,
    308          -SELECTED_TAB_OFFSET);
     307             0,
     308             -SELECTED_TAB_OFFSET);
    309309
    310310  } else
    311311  {
    312312    OffsetRect(itemRect,
    313          -infoPtr->items[infoPtr->leftmostVisible].rect.left,
    314          0);
     313             -infoPtr->items[infoPtr->leftmostVisible].rect.left,
     314             0);
    315315
    316316    /*
     
    319319     */
    320320    OffsetRect(itemRect,
    321          SELECTED_TAB_OFFSET,
    322          0);
     321             SELECTED_TAB_OFFSET,
     322             0);
    323323  }
    324324
     
    336336    /* If it also a bit higher. */
    337337    if ((lStyle & TCS_BOTTOM) && !(lStyle & TCS_VERTICAL))
    338     {
     338    {     
    339339      selectedRect->top -= 2; /* the border is thicker on the bottom */
    340340      selectedRect->bottom += SELECTED_TAB_OFFSET;
     
    362362static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    363363{
    364   return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam,
     364  return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 
    365365                                 (LPRECT)lParam, (LPRECT)NULL);
    366366}
     
    372372 */
    373373static LRESULT TAB_KeyUp(
    374   HWND   hwnd,
     374  HWND   hwnd, 
    375375  WPARAM keyCode)
    376376{
     
    387387      break;
    388388  }
    389 
     389 
    390390  /*
    391391   * If we changed to a valid item, change the selection
     
    416416 */
    417417static LRESULT TAB_FocusChanging(
    418   HWND   hwnd,
    419   UINT   uMsg,
    420   WPARAM wParam,
     418  HWND   hwnd, 
     419  UINT   uMsg, 
     420  WPARAM wParam, 
    421421  LPARAM lParam)
    422422{
     
    429429   */
    430430  isVisible = TAB_InternalGetItemRect(hwnd,
    431                       infoPtr,
    432                       infoPtr->uFocus,
    433                       NULL,
    434                       &selectedRect);
    435 
     431                                      infoPtr,
     432                                      infoPtr->uFocus,
     433                                      NULL,
     434                                      &selectedRect);
     435 
    436436  /*
    437437   * If the rectangle is not completely invisible, invalidate that
     
    451451static HWND TAB_InternalHitTest (
    452452  HWND      hwnd,
    453   TAB_INFO* infoPtr,
    454   POINT     pt,
     453  TAB_INFO* infoPtr, 
     454  POINT     pt, 
    455455  UINT*     flags)
    456456
    457457{
    458458  RECT rect;
    459   int iCount;
    460 
     459  int iCount; 
     460 
    461461  for (iCount = 0; iCount < infoPtr->uNumItem; iCount++)
    462462  {
     
    479479  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    480480  LPTCHITTESTINFO lptest = (LPTCHITTESTINFO) lParam;
    481 
     481 
    482482  return TAB_InternalHitTest (hwnd, infoPtr, lptest->pt, &lptest->flags);
    483483}
     
    521521  if (infoPtr->hwndToolTip)
    522522    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    523             WM_LBUTTONDOWN, wParam, lParam);
     523                    WM_LBUTTONDOWN, wParam, lParam);
    524524
    525525  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) {
     
    529529  if (infoPtr->hwndToolTip)
    530530    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    531             WM_LBUTTONDOWN, wParam, lParam);
    532 
     531                    WM_LBUTTONDOWN, wParam, lParam);
     532 
    533533  pt.x = (INT)LOWORD(lParam);
    534534  pt.y = (INT)HIWORD(lParam);
    535 
     535 
    536536  newItem = TAB_InternalHitTest (hwnd, infoPtr, pt, &dummy);
    537 
     537 
    538538  TRACE("On Tab, item %d\n", newItem);
    539539
     
    619619    ** overlaps.  Note also that the case where the cursor stayed within our
    620620    ** window but has moved off the hot-tracked tab will be handled by the
    621     ** WM_MOUSEMOVE event.
     621    ** WM_MOUSEMOVE event. 
    622622    */
    623623    if (!GetCursorPos(&pt) || WindowFromPoint(pt) != hwnd)
     
    721721    if (item >= 0)
    722722    {
    723     /* Mark new hot-tracked to be redrawn to look highlighted */
     723        /* Mark new hot-tracked to be redrawn to look highlighted */
    724724      if (out_redrawEnter != NULL)
    725725        *out_redrawEnter = item;
     
    743743  if (infoPtr->hwndToolTip)
    744744    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    745             WM_LBUTTONDOWN, wParam, lParam);
     745                    WM_LBUTTONDOWN, wParam, lParam);
    746746
    747747  /* Determine which tab to highlight.  Redraw tabs which change highlight
     
    764764 */
    765765static LRESULT TAB_AdjustRect(
    766   HWND   hwnd,
    767   WPARAM fLarger,
     766  HWND   hwnd, 
     767  WPARAM fLarger, 
    768768  LPRECT prc)
    769769{
     
    845845 */
    846846static LRESULT TAB_OnHScroll(
    847   HWND    hwnd,
     847  HWND    hwnd, 
    848848  int     nScrollCode,
    849849  int     nPos,
     
    871871 * TAB_SetupScrolling
    872872 *
    873  * This method will check the current scrolling state and make sure the
     873 * This method will check the current scrolling state and make sure the 
    874874 * scrolling control is displayed (or not).
    875875 */
     
    930930    {
    931931      infoPtr->hwndUpDown = CreateWindowA("msctls_updown32",
    932                       "",
    933                       WS_VISIBLE | WS_CHILD | UDS_HORZ,
    934                       controlPos.left, controlPos.top,
    935                       controlPos.right - controlPos.left,
    936                       controlPos.bottom - controlPos.top,
    937                       hwnd,
    938                       (HMENU)NULL,
    939                       (HINSTANCE)NULL,
    940                       NULL);
     932                                          "",
     933                                          WS_VISIBLE | WS_CHILD | UDS_HORZ,
     934                                          controlPos.left, controlPos.top,
     935                                          controlPos.right - controlPos.left,
     936                                          controlPos.bottom - controlPos.top,
     937                                          hwnd,
     938                                          (HMENU)NULL,
     939                                          (HINSTANCE)NULL,
     940                                          NULL);       
    941941    }
    942942    else
    943943    {
    944       SetWindowPos(infoPtr->hwndUpDown,
    945            (HWND)NULL,
    946            controlPos.left, controlPos.top,
    947            controlPos.right - controlPos.left,
    948            controlPos.bottom - controlPos.top,
    949            SWP_SHOWWINDOW | SWP_NOZORDER);
     944      SetWindowPos(infoPtr->hwndUpDown, 
     945                   (HWND)NULL,
     946                   controlPos.left, controlPos.top,
     947                   controlPos.right - controlPos.left,
     948                   controlPos.bottom - controlPos.top,
     949                   SWP_SHOWWINDOW | SWP_NOZORDER);                 
    950950    }
    951951
     
    10101010   * a font.
    10111011   */
    1012   hdc = GetDC(hwnd);
    1013 
     1012  hdc = GetDC(hwnd); 
     1013   
    10141014  hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
    10151015  hOldFont = SelectObject (hdc, hFont);
     
    10221022
    10231023  /* if TCS_VERTICAL then swap the height and width so this code places the
    1024      tabs along the top of the rectangle and we can just rotate them after
     1024     tabs along the top of the rectangle and we can just rotate them after 
    10251025     rather than duplicate all of the below code */
    10261026  if(lStyle & TCS_VERTICAL)
     
    10541054
    10551055    /*
    1056      * Make sure there is enough space for the letters + icon + growing the
    1057      * selected item + extra space for the selected item.
     1056     * Make sure there is enough space for the letters + icon + growing the 
     1057     * selected item + extra space for the selected item.   
    10581058     */
    10591059    infoPtr->tabHeight = item_height + 2 * VERTICAL_ITEM_PADDING +
     
    10851085       * for button style tabs */
    10861086      if (lStyle & TCS_BUTTONS)
    1087           size.cx = max(size.cx, 2 * (infoPtr->tabHeight - 2));
     1087              size.cx = max(size.cx, 2 * (infoPtr->tabHeight - 2));
    10881088
    10891089      /* Add the icon width */
     
    10951095
    10961096      infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
    1097                                            size.cx + icon_width +
     1097                                           size.cx + icon_width + 
    10981098                                           num * HORIZONTAL_ITEM_PADDING;
    10991099    }
     
    11141114                                      infoPtr->items[curItem].rect.left;
    11151115
    1116     infoPtr->items[curItem].rect.left = 0;
     1116        infoPtr->items[curItem].rect.left = 0;
    11171117        curItemRowCount++;
    11181118    }
     
    11221122
    11231123    TRACE("TextSize: %li\n", size.cx);
    1124     TRACE("Rect: T %i, L %i, B %i, R %i\n",
    1125       infoPtr->items[curItem].rect.top,
    1126       infoPtr->items[curItem].rect.left,
    1127       infoPtr->items[curItem].rect.bottom,
    1128       infoPtr->items[curItem].rect.right);
     1124    TRACE("Rect: T %i, L %i, B %i, R %i\n", 
     1125          infoPtr->items[curItem].rect.top,
     1126          infoPtr->items[curItem].rect.left,
     1127          infoPtr->items[curItem].rect.bottom,
     1128          infoPtr->items[curItem].rect.right); 
    11291129
    11301130    /*
     
    11521152    /* Don't need scrolling, then update infoPtr->leftmostVisible */
    11531153    if(!infoPtr->needsScrolling)
    1154       infoPtr->leftmostVisible = 0;
     1154      infoPtr->leftmostVisible = 0; 
    11551155
    11561156    TAB_SetupScrolling(hwnd, infoPtr, &clientRect);
     
    11931193
    11941194          /* shift the item to the left side of the clientRect */
    1195           infoPtr->items[iItm].rect.right -=
     1195          infoPtr->items[iItm].rect.right -= 
    11961196            infoPtr->items[iItm].rect.left;
    11971197          infoPtr->items[iItm].rect.left = 0;
     
    12021202          infoPtr->items[iItm].rect.top = iRow;
    12031203          if (lStyle & TCS_BUTTONS)
    1204       {
     1204          {
    12051205            curItemLeftPos = infoPtr->items[iItm].rect.right + 1;
    12061206            if (lStyle & TCS_FLATBUTTONS)
    1207           curItemLeftPos += FLAT_BTN_SPACINGX;
    1208       }
     1207              curItemLeftPos += FLAT_BTN_SPACINGX;
     1208          }
    12091209          else
    12101210            curItemLeftPos = infoPtr->items[iItm].rect.right;
    12111211      }
    1212 
     1212         
    12131213      /*
    12141214       * Justify the rows
     
    12171217         while(iIndexStart < infoPtr->uNumItem)
    12181218        {
    1219         /*
     1219        /* 
    12201220         * find the indexs of the row
    12211221         */
    12221222        /* find the first item on the next row */
    12231223        for (iIndexEnd=iIndexStart;
    1224              (iIndexEnd < infoPtr->uNumItem) &&
    1225            (infoPtr->items[iIndexEnd].rect.top ==
     1224             (iIndexEnd < infoPtr->uNumItem) && 
     1225               (infoPtr->items[iIndexEnd].rect.top ==
    12261226                infoPtr->items[iIndexStart].rect.top) ;
    12271227            iIndexEnd++)
    12281228        /* intentionaly blank */;
    12291229
    1230         /*
     1230        /* 
    12311231         * we need to justify these tabs so they fill the whole given
    12321232         * client area
     
    12461246           widthDiff = widthDiff / iCount;
    12471247           /* add widthDiff/iCount, or extra space/items on row, to each item on this row */
    1248            for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd;
     1248           for (iIndex=iIndexStart,iCount=0; iIndex < iIndexEnd; 
    12491249                iIndex++,iCount++)
    12501250           {
     
    12971297 * This method is used to draw the interior (text and icon) of a single tab
    12981298 * into the tab control.
    1299  */
     1299 */         
    13001300static void
    13011301TAB_DrawItemInterior
     
    13901390    id = GetWindowLongA( hwnd, GWL_ID );
    13911391
    1392     /*
     1392    /* 
    13931393     * put together the DRAWITEMSTRUCT
    13941394     */
    1395     dis.CtlType    = ODT_TAB;
    1396     dis.CtlID      = id;
    1397     dis.itemID     = iItem;
    1398     dis.itemAction = ODA_DRAWENTIRE;
     1395    dis.CtlType    = ODT_TAB;   
     1396    dis.CtlID      = id;               
     1397    dis.itemID     = iItem;             
     1398    dis.itemAction = ODA_DRAWENTIRE;   
    13991399    if ( iItem == infoPtr->iSelected )
    1400       dis.itemState = ODS_SELECTED;
    1401     else
    1402       dis.itemState = 0;
    1403     dis.hwndItem = hwnd;        /* */
    1404     dis.hDC      = hdc;
    1405     dis.rcItem   = *drawRect;       /* */
     1400      dis.itemState = ODS_SELECTED;     
     1401    else                               
     1402      dis.itemState = 0;               
     1403    dis.hwndItem = hwnd;                /* */
     1404    dis.hDC      = hdc;         
     1405    dis.rcItem   = *drawRect;           /* */
    14061406    dis.itemData = infoPtr->items[iItem].lParam;
    14071407
     
    15381538    if(lStyle & TCS_VERTICAL)
    15391539    {
    1540       if (!GetObjectA((infoPtr->hFont) ?
     1540      if (!GetObjectA((infoPtr->hFont) ? 
    15411541                infoPtr->hFont : GetStockObject(SYSTEM_FONT),
    15421542                sizeof(LOGFONTA),&logfont))
     
    15451545
    15461546        lstrcpyA(logfont.lfFaceName, "Arial");
    1547         logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY),
     1547        logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 
    15481548                                    72);
    15491549        logfont.lfWeight = FW_NORMAL;
     
    16041604 *
    16051605 * This method is used to draw a single tab into the tab control.
    1606  */
     1606 */         
    16071607static void TAB_DrawItem(
    1608   HWND hwnd,
    1609   HDC  hdc,
     1608  HWND hwnd, 
     1609  HDC  hdc, 
    16101610  INT  iItem)
    16111611{
     
    16211621   */
    16221622  isVisible = TAB_InternalGetItemRect(hwnd,
    1623                       infoPtr,
    1624                       iItem,
    1625                       &itemRect,
    1626                       &selectedRect);
     1623                                      infoPtr,
     1624                                      iItem,
     1625                                      &itemRect,
     1626                                      &selectedRect);
    16271627
    16281628  if (isVisible)
    16291629  {
    1630     HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));
     1630    HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));   
    16311631    HPEN   hwPen     = GetSysColorPen (COLOR_3DHILIGHT);
    16321632    HPEN hbPen  = GetSysColorPen (COLOR_3DDKSHADOW);
     
    16451645      /* Separators between flat buttons */
    16461646      /* FIXME: test and correct this if necessary for TCS_FLATBUTTONS style */
    1647       if (lStyle & TCS_FLATBUTTONS)
     1647      if (lStyle & TCS_FLATBUTTONS) 
    16481648      {
    16491649        int x = r.right + FLAT_BTN_SPACINGX - 2;
     
    16691669        /* Background color */
    16701670        if (!((lStyle & TCS_OWNERDRAWFIXED) && infoPtr->fSizeSet))
    1671     {
     1671        {
    16721672              COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
    16731673              DeleteObject(hbr);
     
    16851685
    16861686              deleteBrush = FALSE;
    1687     }
     1687        }
    16881688
    16891689        /* Erase the background */
     
    17041704        LineTo   (hdc, r.right, r.bottom);
    17051705        LineTo   (hdc, r.right, r.top + 1);
    1706 
     1706       
    17071707        /* shadow */
    17081708        SelectObject(hdc, hbPen);
     
    17211721        FillRect(hdc, &r, hbr);
    17221722
    1723     if (!(lStyle & TCS_FLATBUTTONS))
    1724     {
     1723        if (!(lStyle & TCS_FLATBUTTONS))
     1724        {
    17251725          /* highlight */
    17261726          MoveToEx (hdc, r.left, r.bottom, NULL);
    17271727          LineTo   (hdc, r.left, r.top);
    17281728          LineTo   (hdc, r.right, r.top);
    1729 
     1729         
    17301730          /* shadow */
    17311731          SelectObject(hdc, hbPen);
     
    17381738          LineTo   (hdc, r.right - 1, r.bottom - 1);
    17391739          LineTo   (hdc, r.left + 1, r.bottom - 1);
    1740     }
     1740        }
    17411741      }
    17421742    }
     
    17451745      /* Background color */
    17461746      DeleteObject(hbr);
    1747       hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
     1747      hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));   
    17481748
    17491749      /* We draw a rectangle of different sizes depending on the selection
     
    17561756      /*
    17571757       * Erase the background.
    1758        * This is necessary when drawing the selected item since it is larger
    1759        * than the others, it might overlap with stuff already drawn by the
     1758       * This is necessary when drawing the selected item since it is larger 
     1759       * than the others, it might overlap with stuff already drawn by the 
    17601760       * other tabs
    1761        */
     1761       */     
    17621762      FillRect(hdc, &r, hbr);
    17631763
     
    17701770      r.right--;
    17711771      r.bottom--;
    1772 
     1772     
    17731773      holdPen = SelectObject (hdc, hwPen);
    17741774      if(lStyle & TCS_VERTICAL)
     
    18591859      }
    18601860    }
    1861 
     1861 
    18621862    /* This modifies r to be the text rectangle. */
    18631863{
     
    18681868    /* Draw the focus rectangle */
    18691869    if (((lStyle & TCS_FOCUSNEVER) == 0) &&
    1870     (GetFocus() == hwnd) &&
    1871     (iItem == infoPtr->uFocus) )
     1870        (GetFocus() == hwnd) &&
     1871        (iItem == infoPtr->uFocus) )
    18721872    {
    18731873      r = itemRect;
     
    18881888 * This method is used to draw the raised border around the tab control
    18891889 * "content" area.
    1890  */
     1890 */         
    18911891static void TAB_DrawBorder (HWND hwnd, HDC hdc)
    18921892{
     
    19571957 *
    19581958 * This method repaints the tab control..
    1959  */
     1959 */             
    19601960static void TAB_Refresh (HWND hwnd, HDC hdc)
    19611961{
     
    19711971  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS)
    19721972  {
    1973     for (i = 0; i < infoPtr->uNumItem; i++)
     1973    for (i = 0; i < infoPtr->uNumItem; i++) 
    19741974      TAB_DrawItem (hwnd, hdc, i);
    19751975  }
     
    19771977  {
    19781978    /* Draw all the non selected item first */
    1979     for (i = 0; i < infoPtr->uNumItem; i++)
     1979    for (i = 0; i < infoPtr->uNumItem; i++) 
    19801980    {
    19811981      if (i != infoPtr->iSelected)
    1982     TAB_DrawItem (hwnd, hdc, i);
     1982        TAB_DrawItem (hwnd, hdc, i);
    19831983    }
    19841984
     
    20112011{
    20122012    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2013 
     2013 
    20142014  infoPtr->DoRedraw=(BOOL) wParam;
    20152015  return 0;
     
    20172017
    20182018static LRESULT TAB_EraseBackground(
    2019   HWND hwnd,
     2019  HWND hwnd, 
    20202020  HDC  givenDC)
    20212021{
     
    22072207  HDC hdc;
    22082208  PAINTSTRUCT ps;
    2209 
     2209   
    22102210  hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    22112211  TAB_Refresh (hwnd, hdc);
    2212 
     2212   
    22132213  if(!wParam)
    22142214    EndPaint (hwnd, &ps);
     
    22192219static LRESULT
    22202220TAB_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    2221 {
     2221{   
    22222222  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    22232223  TCITEMA *pti;
    22242224  INT iItem;
    22252225  RECT rect;
    2226 
     2226 
    22272227  GetClientRect (hwnd, &rect);
    22282228  TRACE("Rect: %x T %i, L %i, B %i, R %i\n", hwnd,
    2229         rect.top, rect.left, rect.bottom, rect.right);
    2230 
     2229        rect.top, rect.left, rect.bottom, rect.right); 
     2230 
    22312231  pti = (TCITEMA *)lParam;
    22322232  iItem = (INT)wParam;
    2233 
     2233 
    22342234  if (iItem < 0) return -1;
    22352235  if (iItem > infoPtr->uNumItem)
    22362236    iItem = infoPtr->uNumItem;
    2237 
     2237 
    22382238  if (infoPtr->uNumItem == 0) {
    22392239    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
     
    22432243  else {
    22442244    TAB_ITEM *oldItems = infoPtr->items;
    2245 
     2245   
    22462246    infoPtr->uNumItem++;
    22472247    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2248 
     2248   
    22492249    /* pre insert copy */
    22502250    if (iItem > 0) {
    22512251      memcpy (&infoPtr->items[0], &oldItems[0],
    2252           iItem * sizeof(TAB_ITEM));
    2253     }
    2254 
     2252              iItem * sizeof(TAB_ITEM));
     2253    }
     2254   
    22552255    /* post insert copy */
    22562256    if (iItem < infoPtr->uNumItem - 1) {
    22572257      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    2258           (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    2259 
     2258              (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     2259     
    22602260    }
    22612261
     
    22652265    COMCTL32_Free (oldItems);
    22662266  }
    2267 
     2267 
    22682268  infoPtr->items[iItem].mask = pti->mask;
    22692269  if (pti->mask & TCIF_TEXT)
     
    22722272  if (pti->mask & TCIF_IMAGE)
    22732273    infoPtr->items[iItem].iImage = pti->iImage;
    2274 
     2274 
    22752275  if (pti->mask & TCIF_PARAM)
    22762276    infoPtr->items[iItem].lParam = pti->lParam;
    2277 
     2277 
    22782278  TAB_SetItemBounds(hwnd);
    22792279  TAB_InvalidateTabArea(hwnd, infoPtr);
    2280 
     2280 
    22812281  TRACE("[%04x]: added item %d '%s'\n",
    2282     hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
     2282        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    22832283
    22842284  return iItem;
     
    23192319    if (iItem > 0) {
    23202320      memcpy (&infoPtr->items[0], &oldItems[0],
    2321           iItem * sizeof(TAB_ITEM));
     2321              iItem * sizeof(TAB_ITEM));
    23222322    }
    23232323
     
    23252325    if (iItem < infoPtr->uNumItem - 1) {
    23262326      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    2327           (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    2328 
    2329   }
    2330 
     2327              (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     2328
     2329  }
     2330 
    23312331    if (iItem <= infoPtr->iSelected)
    23322332      infoPtr->iSelected++;
     
    23412341  if (pti->mask & TCIF_IMAGE)
    23422342    infoPtr->items[iItem].iImage = pti->iImage;
    2343 
     2343 
    23442344  if (pti->mask & TCIF_PARAM)
    23452345    infoPtr->items[iItem].lParam = pti->lParam;
    2346 
     2346 
    23472347  TAB_SetItemBounds(hwnd);
    23482348  TAB_InvalidateTabArea(hwnd, infoPtr);
    2349 
     2349 
    23502350  TRACE("[%04x]: added item %d '%s'\n",
    2351     hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
     2351        hwnd, iItem, debugstr_w(infoPtr->items[iItem].pszText));
    23522352
    23532353  return iItem;
     
    23552355
    23562356
    2357 static LRESULT
     2357static LRESULT 
    23582358TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23592359{
     
    23732373}
    23742374
    2375 static LRESULT
     2375static LRESULT 
    23762376TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    23772377{
    23782378  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2379   TCITEMA *tabItem;
     2379  TCITEMA *tabItem; 
    23802380  TAB_ITEM *wineItem;
    23812381  INT    iItem;
     
    23952395    wineItem->lParam = tabItem->lParam;
    23962396
    2397   if (tabItem->mask & TCIF_RTLREADING)
     2397  if (tabItem->mask & TCIF_RTLREADING) 
    23982398    FIXME("TCIF_RTLREADING\n");
    23992399
    2400   if (tabItem->mask & TCIF_STATE)
     2400  if (tabItem->mask & TCIF_STATE) 
    24012401    wineItem->dwState = tabItem->dwState;
    24022402
     
    24512451
    24522452
    2453 static LRESULT
     2453static LRESULT 
    24542454TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24552455{
     
    24602460
    24612461
    2462 static LRESULT
     2462static LRESULT 
    24632463TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24642464{
     
    24762476  wineItem = &infoPtr->items[iItem];
    24772477
    2478   if (tabItem->mask & TCIF_IMAGE)
     2478  if (tabItem->mask & TCIF_IMAGE) 
    24792479    tabItem->iImage = wineItem->iImage;
    24802480
    2481   if (tabItem->mask & TCIF_PARAM)
     2481  if (tabItem->mask & TCIF_PARAM) 
    24822482    tabItem->lParam = wineItem->lParam;
    24832483
    2484   if (tabItem->mask & TCIF_RTLREADING)
     2484  if (tabItem->mask & TCIF_RTLREADING) 
    24852485    FIXME("TCIF_RTLREADING\n");
    24862486
    2487   if (tabItem->mask & TCIF_STATE)
     2487  if (tabItem->mask & TCIF_STATE) 
    24882488    tabItem->dwState = wineItem->dwState;
    24892489
    2490   if (tabItem->mask & TCIF_TEXT)
     2490  if (tabItem->mask & TCIF_TEXT) 
    24912491   Str_GetPtrWtoA (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax);
    24922492
     
    24952495
    24962496
    2497 static LRESULT
     2497static LRESULT 
    24982498TAB_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
    24992499{
     
    25302530
    25312531
    2532 static LRESULT
     2532static LRESULT 
    25332533TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25342534{
     
    25402540  {
    25412541    TAB_ITEM *oldItems = infoPtr->items;
    2542 
     2542   
    25432543    infoPtr->uNumItem--;
    25442544    infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem);
    2545 
    2546     if (iItem > 0)
     2545   
     2546    if (iItem > 0) 
    25472547      memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM));
    2548 
    2549     if (iItem < infoPtr->uNumItem)
     2548   
     2549    if (iItem < infoPtr->uNumItem) 
    25502550      memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1],
    25512551              (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM));
    2552 
     2552   
    25532553    COMCTL32_Free(oldItems);
    25542554
     
    25562556    if ((iItem == infoPtr->iSelected) && (iItem > 0))
    25572557      infoPtr->iSelected--;
    2558 
     2558     
    25592559    if (iItem < infoPtr->iSelected)
    25602560      infoPtr->iSelected--;
     
    25732573}
    25742574
    2575 static LRESULT
     2575static LRESULT 
    25762576TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
    25772577{
     
    25842584    KillTimer(hwnd, TAB_HOTTRACK_TIMER);
    25852585  infoPtr->iHotTracked = -1;
    2586 
     2586 
    25872587  TAB_SetItemBounds(hwnd);
    25882588  TAB_InvalidateTabArea(hwnd,infoPtr);
     
    26052605{
    26062606  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    2607 
     2607 
    26082608  TRACE("%x %lx\n",wParam, lParam);
    2609 
     2609 
    26102610  infoPtr->hFont = (HFONT)wParam;
    2611 
     2611 
    26122612  TAB_SetItemBounds(hwnd);
    26132613
     
    26762676    cx=LOWORD (lParam);
    26772677    cy=HIWORD (lParam);
    2678     if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE)
     2678    if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 
    26792679        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    26802680
     
    26952695
    26962696
    2697 static LRESULT
     2697static LRESULT 
    26982698TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    26992699{
     
    27112711
    27122712  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    2713 
     2713   
    27142714  infoPtr->uNumItem        = 0;
    27152715  infoPtr->uNumRows        = 0;
     
    27192719  infoPtr->iSelected       = -1;
    27202720  infoPtr->iHotTracked     = -1;
    2721   infoPtr->uFocus          = -1;
     2721  infoPtr->uFocus          = -1; 
    27222722  infoPtr->hwndToolTip     = 0;
    27232723  infoPtr->DoRedraw        = TRUE;
     
    27252725  infoPtr->hwndUpDown      = 0;
    27262726  infoPtr->leftmostVisible = 0;
    2727   infoPtr->fSizeSet    = FALSE;
    2728   infoPtr->bUnicode    = IsWindowUnicode (hwnd);
    2729 
    2730   TRACE("Created tab control, hwnd [%04x]\n", hwnd);
    2731 
    2732   /* The tab control always has the WS_CLIPSIBLINGS style. Even
    2733      if you don't specify it in CreateWindow. This is necessary in
     2727  infoPtr->fSizeSet        = FALSE;
     2728  infoPtr->bUnicode        = IsWindowUnicode (hwnd);
     2729 
     2730  TRACE("Created tab control, hwnd [%04x]\n", hwnd); 
     2731
     2732  /* The tab control always has the WS_CLIPSIBLINGS style. Even 
     2733     if you don't specify it in CreateWindow. This is necessary in 
    27342734     order for paint to work correctly. This follows windows behaviour. */
    27352735  dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
     
    27402740    infoPtr->hwndToolTip =
    27412741      CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    2742                CW_USEDEFAULT, CW_USEDEFAULT,
    2743                CW_USEDEFAULT, CW_USEDEFAULT,
    2744                hwnd, 0, 0, 0);
    2745 
     2742                       CW_USEDEFAULT, CW_USEDEFAULT,
     2743                       CW_USEDEFAULT, CW_USEDEFAULT,
     2744                       hwnd, 0, 0, 0);
     2745   
    27462746    /* Send NM_TOOLTIPSCREATED notification */
    27472747    if (infoPtr->hwndToolTip) {
    27482748      NMTOOLTIPSCREATED nmttc;
    2749 
     2749     
    27502750      nmttc.hdr.hwndFrom = hwnd;
    27512751      nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
    27522752      nmttc.hdr.code = NM_TOOLTIPSCREATED;
    27532753      nmttc.hwndToolTips = infoPtr->hwndToolTip;
    2754 
     2754     
    27552755      SendMessageA (GetParent (hwnd), WM_NOTIFY,
    2756             (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
    2757     }
    2758   }
    2759 
     2756                    (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
     2757    }
     2758  } 
     2759   
    27602760  /*
    27612761   * We need to get text information so we need a DC and we need to select
    27622762   * a font.
    27632763   */
    2764   hdc = GetDC(hwnd);
     2764  hdc = GetDC(hwnd); 
    27652765  hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
    27662766
     
    27692769
    27702770  /*
    2771    * Make sure there is enough space for the letters + growing the
    2772    * selected item + extra space for the selected item.
     2771   * Make sure there is enough space for the letters + growing the 
     2772   * selected item + extra space for the selected item.   
    27732773   */
    27742774  infoPtr->tabHeight = fontMetrics.tmHeight + 2 * VERTICAL_ITEM_PADDING +
     
    27962796    for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) {
    27972797      if (infoPtr->items[iItem].pszText)
    2798     COMCTL32_Free (infoPtr->items[iItem].pszText);
     2798        COMCTL32_Free (infoPtr->items[iItem].pszText);
    27992799    }
    28002800    COMCTL32_Free (infoPtr->items);
    28012801  }
    2802 
    2803   if (infoPtr->hwndToolTip)
     2802 
     2803  if (infoPtr->hwndToolTip) 
    28042804    DestroyWindow (infoPtr->hwndToolTip);
    2805 
     2805 
    28062806  if (infoPtr->hwndUpDown)
    28072807    DestroyWindow(infoPtr->hwndUpDown);
     
    28272827    case TCM_GETIMAGELIST:
    28282828      return TAB_GetImageList (hwnd, wParam, lParam);
    2829 
     2829     
    28302830    case TCM_SETIMAGELIST:
    28312831      return TAB_SetImageList (hwnd, wParam, lParam);
    2832 
     2832     
    28332833    case TCM_GETITEMCOUNT:
    28342834      return TAB_GetItemCount (hwnd, wParam, lParam);
    2835 
     2835     
    28362836    case TCM_GETITEMA:
    28372837      return TAB_GetItemA (hwnd, wParam, lParam);
    2838 
     2838     
    28392839    case TCM_GETITEMW:
    28402840      return TAB_GetItemW (hwnd, wParam, lParam);
    2841 
     2841     
    28422842    case TCM_SETITEMA:
    28432843      return TAB_SetItemA (hwnd, wParam, lParam);
    2844 
     2844     
    28452845    case TCM_SETITEMW:
    28462846      return TAB_SetItemW (hwnd, wParam, lParam);
    2847 
     2847     
    28482848    case TCM_DELETEITEM:
    28492849      return TAB_DeleteItem (hwnd, wParam, lParam);
    2850 
     2850     
    28512851    case TCM_DELETEALLITEMS:
    28522852     return TAB_DeleteAllItems (hwnd, wParam, lParam);
    2853 
     2853     
    28542854    case TCM_GETITEMRECT:
    28552855     return TAB_GetItemRect (hwnd, wParam, lParam);
    2856 
     2856     
    28572857    case TCM_GETCURSEL:
    28582858      return TAB_GetCurSel (hwnd);
    2859 
     2859     
    28602860    case TCM_HITTEST:
    28612861      return TAB_HitTest (hwnd, wParam, lParam);
    2862 
     2862     
    28632863    case TCM_SETCURSEL:
    28642864      return TAB_SetCurSel (hwnd, wParam);
    2865 
     2865     
    28662866    case TCM_INSERTITEMA:
    28672867      return TAB_InsertItemA (hwnd, wParam, lParam);
    2868 
     2868     
    28692869    case TCM_INSERTITEMW:
    28702870      return TAB_InsertItemW (hwnd, wParam, lParam);
    2871 
     2871     
    28722872    case TCM_SETITEMEXTRA:
    28732873      FIXME("Unimplemented msg TCM_SETITEMEXTRA\n");
    28742874      return 0;
    2875 
     2875     
    28762876    case TCM_ADJUSTRECT:
    28772877      return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam);
    2878 
     2878     
    28792879    case TCM_SETITEMSIZE:
    28802880      return TAB_SetItemSize (hwnd, wParam, lParam);
    2881 
     2881     
    28822882    case TCM_REMOVEIMAGE:
    28832883      FIXME("Unimplemented msg TCM_REMOVEIMAGE\n");
    28842884      return 0;
    2885 
     2885     
    28862886    case TCM_SETPADDING:
    28872887      FIXME("Unimplemented msg TCM_SETPADDING\n");
    28882888      return 0;
    2889 
     2889     
    28902890    case TCM_GETROWCOUNT:
    28912891      return TAB_GetRowCount(hwnd);
     
    29002900      FIXME("Unimplemented msg TCM_HIGHLIGHTITEM\n");
    29012901      return 0;
    2902 
     2902     
    29032903    case TCM_GETTOOLTIPS:
    29042904      return TAB_GetToolTips (hwnd, wParam, lParam);
    2905 
     2905     
    29062906    case TCM_SETTOOLTIPS:
    29072907      return TAB_SetToolTips (hwnd, wParam, lParam);
    2908 
     2908     
    29092909    case TCM_GETCURFOCUS:
    29102910      return TAB_GetCurFocus (hwnd);
    2911 
     2911     
    29122912    case TCM_SETCURFOCUS:
    29132913      return TAB_SetCurFocus (hwnd, wParam);
    2914 
     2914     
    29152915    case TCM_SETMINTABWIDTH:
    29162916      FIXME("Unimplemented msg TCM_SETMINTABWIDTH\n");
    29172917      return 0;
    2918 
     2918     
    29192919    case TCM_DESELECTALL:
    29202920      FIXME("Unimplemented msg TCM_DESELECTALL\n");
    29212921      return 0;
    2922 
     2922     
    29232923    case TCM_GETEXTENDEDSTYLE:
    29242924      FIXME("Unimplemented msg TCM_GETEXTENDEDSTYLE\n");
     
    29312931    case WM_GETFONT:
    29322932      return TAB_GetFont (hwnd, wParam, lParam);
    2933 
     2933     
    29342934    case WM_SETFONT:
    29352935      return TAB_SetFont (hwnd, wParam, lParam);
    2936 
     2936     
    29372937    case WM_CREATE:
    29382938      return TAB_Create (hwnd, wParam, lParam);
    2939 
     2939     
    29402940    case WM_NCDESTROY:
    29412941      return TAB_Destroy (hwnd, wParam, lParam);
    2942 
     2942     
    29432943    case WM_GETDLGCODE:
    29442944      return DLGC_WANTARROWS | DLGC_WANTCHARS;
    2945 
     2945     
    29462946    case WM_LBUTTONDOWN:
    29472947      return TAB_LButtonDown (hwnd, wParam, lParam);
    2948 
     2948     
    29492949    case WM_LBUTTONUP:
    29502950      return TAB_LButtonUp (hwnd, wParam, lParam);
    2951 
     2951     
    29522952    case WM_RBUTTONDOWN:
    29532953      return TAB_RButtonDown (hwnd, wParam, lParam);
    2954 
     2954     
    29552955    case WM_MOUSEMOVE:
    29562956      return TAB_MouseMove (hwnd, wParam, lParam);
    2957 
     2957     
    29582958    case WM_ERASEBKGND:
    29592959      return TAB_EraseBackground (hwnd, (HDC)wParam);
     
    29642964    case WM_SIZE:
    29652965      return TAB_Size (hwnd, wParam, lParam);
    2966 
     2966     
    29672967    case WM_SETREDRAW:
    29682968      return TAB_SetRedraw (hwnd, wParam);
     
    29752975      InvalidateRect(hwnd, NULL, TRUE);
    29762976      return 0;
    2977 
     2977     
    29782978    case WM_KILLFOCUS:
    29792979    case WM_SETFOCUS:
     
    29872987    default:
    29882988      if (uMsg >= WM_USER)
    2989     WARN("unknown msg %04x wp=%08x lp=%08lx\n",
    2990          uMsg, wParam, lParam);
     2989        WARN("unknown msg %04x wp=%08x lp=%08lx\n",
     2990             uMsg, wParam, lParam);
    29912991#ifdef __WIN32OS2__
    29922992      return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     
    30133013  wndClass.hbrBackground = (HBRUSH)NULL;
    30143014  wndClass.lpszClassName = WC_TABCONTROLA;
    3015 
     3015 
    30163016  RegisterClassA (&wndClass);
    30173017}
Note: See TracChangeset for help on using the changeset viewer.