Ignore:
Timestamp:
Jun 28, 1999, 5:46:28 PM (26 years ago)
Author:
cbratschi
Message:

bug fixes (unicode) and improvements

File:
1 edited

Legend:

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

    r164 r236  
    1 /* $Id: tab.c,v 1.5 1999-06-23 19:45:01 achimha Exp $ */
     1/* $Id: tab.c,v 1.6 1999-06-28 15:46:26 cbratschi Exp $ */
    22/*
    33 * Tab control
     
    77 * Copyright 1999 Francis Beaudet
    88 * Copyright 1999 Achim Hasenmueller
     9 * Copyright 1999 Christoph Bratschi
    910 *
    1011 * TODO:
     
    8384{
    8485    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    85  
     86
    8687    return infoPtr->iSelected;
    8788}
     
    9192{
    9293    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    93  
     94
    9495    return infoPtr->uFocus;
    9596}
     
    111112  INT iItem=(INT) wParam;
    112113  INT prevItem;
    113  
     114
    114115  prevItem=-1;
    115116  if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) {
     
    125126  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    126127  INT iItem=(INT) wParam;
    127  
     128
    128129  if ((iItem < 0) || (iItem > infoPtr->uNumItem)) return 0;
    129130
     
    131132  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
    132133//    FIXME (tab,"Should set input focus\n");
    133   } else { 
     134  } else {
    134135    if (infoPtr->iSelected != iItem) {
    135136      if (TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)!=TRUE)  {
     
    137138        TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE);
    138139
    139         TAB_EnsureSelectionVisible(hwnd, infoPtr);
    140         TAB_InvalidateTabArea(hwnd, infoPtr);
     140        TAB_EnsureSelectionVisible(hwnd, infoPtr);
     141        TAB_InvalidateTabArea(hwnd, infoPtr);
    141142      }
    142143    }
     
    176177   * Perform a sanity check and a trivial visibility check.
    177178   */
    178   if ( (infoPtr->uNumItem <=0) ||
     179  if ( (infoPtr->uNumItem == 0) ||
    179180       (itemIndex >= infoPtr->uNumItem) ||
    180181       (itemIndex < infoPtr->leftmostVisible) )
     
    187188  if (itemRect==NULL)
    188189    itemRect = &tmpItemRect;
    189  
     190
    190191  /*
    191192   * Retrieve the unmodified item rect.
     
    194195
    195196  /*
    196    * "scroll" it to make sure the item at the very left of the 
     197   * "scroll" it to make sure the item at the very left of the
    197198   * tab control is the leftmost visible tab.
    198199   */
    199200  OffsetRect(itemRect,
    200              -infoPtr->items[infoPtr->leftmostVisible].rect.left,
    201              0);
    202 
    203   /*
    204    * Move the rectangle so the first item is slightly offset from 
     201             -infoPtr->items[infoPtr->leftmostVisible].rect.left,
     202             0);
     203
     204  /*
     205   * Move the rectangle so the first item is slightly offset from
    205206   * the left of the tab control.
    206207   */
    207208  OffsetRect(itemRect,
    208              SELECTED_TAB_OFFSET,
    209              0);
     209             SELECTED_TAB_OFFSET,
     210             0);
    210211
    211212
     
    225226     * If it also a bit higher.
    226227     */
    227     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
    228     {     
     228    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
     229    {
    229230      selectedRect->top    -=2; /* the border is thicker on the bottom */
    230231      selectedRect->bottom +=SELECTED_TAB_OFFSET;
     
    242243static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam)
    243244{
    244   return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 
     245  return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam,
    245246                                 (LPRECT)lParam, (LPRECT)NULL);
    246247}
     
    252253 */
    253254static LRESULT TAB_KeyUp(
    254   HWND   hwnd, 
     255  HWND   hwnd,
    255256  WPARAM keyCode)
    256257{
     
    267268      break;
    268269  }
    269  
     270
    270271  /*
    271272   * If we changed to a valid item, change the selection
     
    296297 */
    297298static LRESULT TAB_FocusChanging(
    298   HWND   hwnd, 
    299   UINT   uMsg, 
    300   WPARAM wParam, 
     299  HWND   hwnd,
     300  UINT   uMsg,
     301  WPARAM wParam,
    301302  LPARAM lParam)
    302303{
     
    309310   */
    310311  isVisible = TAB_InternalGetItemRect(hwnd,
    311                                       infoPtr,
    312                                       infoPtr->uFocus,
    313                                       NULL,
    314                                       &selectedRect);
    315  
     312                                      infoPtr,
     313                                      infoPtr->uFocus,
     314                                      NULL,
     315                                      &selectedRect);
     316
    316317  /*
    317318   * If the rectangle is not completely invisible, invalidate that
     
    331332static HWND TAB_InternalHitTest (
    332333  HWND      hwnd,
    333   TAB_INFO* infoPtr, 
    334   POINT     pt, 
     334  TAB_INFO* infoPtr,
     335  POINT     pt,
    335336  UINT*     flags)
    336337
    337338{
    338339  RECT rect;
    339   int iCount; 
    340  
    341   for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) 
     340  int iCount;
     341
     342  for (iCount = 0; iCount < infoPtr->uNumItem; iCount++)
    342343  {
    343344    TAB_InternalGetItemRect(hwnd,
    344                             infoPtr,
    345                             iCount,
    346                             &rect,
    347                             NULL);
     345                            infoPtr,
     346                            iCount,
     347                            &rect,
     348                            NULL);
    348349
    349350    if (PtInRect (&rect, pt))
     
    363364  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    364365  LPTCHITTESTINFO lptest=(LPTCHITTESTINFO) lParam;
    365  
     366
    366367  return TAB_InternalHitTest (hwnd, infoPtr,lptest->pt,&lptest->flags);
    367368}
     
    375376  if (infoPtr->hwndToolTip)
    376377    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    377                     WM_LBUTTONDOWN, wParam, lParam);
     378                    WM_LBUTTONDOWN, wParam, lParam);
    378379
    379380  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) {
     
    389390  POINT pt;
    390391  INT newItem,dummy;
    391  
     392
    392393  if (infoPtr->hwndToolTip)
    393394    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    394                     WM_LBUTTONDOWN, wParam, lParam);
    395  
     395                    WM_LBUTTONDOWN, wParam, lParam);
     396
    396397  pt.x = (INT)LOWORD(lParam);
    397398  pt.y = (INT)HIWORD(lParam);
    398  
     399
    399400  newItem=TAB_InternalHitTest (hwnd, infoPtr,pt,(unsigned int*)&dummy);
    400  
     401
    401402//  TRACE(tab, "On Tab, item %d\n", newItem);
    402    
     403
    403404  if ( (newItem!=-1) &&
    404405       (infoPtr->iSelected != newItem) )
     
    434435  if (infoPtr->hwndToolTip)
    435436    TAB_RelayEvent (infoPtr->hwndToolTip, hwnd,
    436                     WM_LBUTTONDOWN, wParam, lParam);
     437                    WM_LBUTTONDOWN, wParam, lParam);
    437438  return 0;
    438439}
     
    445446 */
    446447static LRESULT TAB_AdjustRect(
    447   HWND   hwnd, 
    448   WPARAM fLarger, 
     448  HWND   hwnd,
     449  WPARAM fLarger,
    449450  LPRECT prc)
    450451{
    451452  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    452453
    453   if (fLarger) 
     454  if (fLarger)
    454455  {
    455456    /*
     
    460461     * Add the height of the tabs.
    461462     */
    462     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     463    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    463464      prc->bottom += infoPtr->tabHeight;
    464465    else
     
    475476    InflateRect(prc, CONTROL_BORDER_SIZEX, CONTROL_BORDER_SIZEX);
    476477  }
    477   else 
     478  else
    478479  {
    479480    /*
    480481     * Go from window rectangle.
    481482     */
    482  
     483
    483484    /*
    484485     * Deflate the rectangle for the border
     
    494495     * Remove the height of the tabs.
    495496     */
    496     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     497    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    497498      prc->bottom -= infoPtr->tabHeight;
    498499    else
     
    500501
    501502  }
    502  
     503
    503504  return 0;
    504505}
     
    511512 */
    512513static LRESULT TAB_OnHScroll(
    513   HWND    hwnd, 
     514  HWND    hwnd,
    514515  int     nScrollCode,
    515516  int     nPos,
     
    543544 * TAB_SetupScroling
    544545 *
    545  * This method will check the current scrolling state and make sure the 
     546 * This method will check the current scrolling state and make sure the
    546547 * scrolling control is displayed (or not).
    547548 */
     
    561562    controlPos.left  = controlPos.right - 2*GetSystemMetrics(SM_CXHSCROLL);
    562563
    563     if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     564    if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    564565    {
    565566      controlPos.top    = clientRect->bottom - infoPtr->tabHeight;
     
    583584       */
    584585      infoPtr->hwndUpDown = CreateWindowA("ScrollBar",
    585                                           "",
    586                                           WS_VISIBLE | WS_CHILD | WS_OVERLAPPED | SBS_HORZ,
    587                                           controlPos.left, controlPos.top,
    588                                           controlPos.right - controlPos.left,
    589                                           controlPos.bottom - controlPos.top,
    590                                           hwnd,
    591                                           (HMENU)NULL,
    592                                           (HINSTANCE)NULL,
    593                                           NULL);       
     586                                          "",
     587                                          WS_VISIBLE | WS_CHILD | WS_OVERLAPPED | SBS_HORZ,
     588                                          controlPos.left, controlPos.top,
     589                                          controlPos.right - controlPos.left,
     590                                          controlPos.bottom - controlPos.top,
     591                                          hwnd,
     592                                          (HMENU)NULL,
     593                                          (HINSTANCE)NULL,
     594                                          NULL);
    594595    }
    595596    else
    596597    {
    597       SetWindowPos(infoPtr->hwndUpDown, 
    598                    (HWND)NULL,
    599                    controlPos.left, controlPos.top,
    600                    controlPos.right - controlPos.left,
    601                    controlPos.bottom - controlPos.top,
    602                    SWP_SHOWWINDOW | SWP_NOZORDER);                 
     598      SetWindowPos(infoPtr->hwndUpDown,
     599                   (HWND)NULL,
     600                   controlPos.left, controlPos.top,
     601                   controlPos.right - controlPos.left,
     602                   controlPos.bottom - controlPos.top,
     603                   SWP_SHOWWINDOW | SWP_NOZORDER);
    603604    }
    604605  }
     
    641642   * a font.
    642643   */
    643   hdc = GetDC(hwnd); 
    644    
     644  hdc = GetDC(hwnd);
     645
    645646  hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
    646647  hOldFont = SelectObject (hdc, hFont);
     
    651652   */
    652653  GetClientRect(hwnd, &clientRect);
    653  
     654
    654655  /*
    655656   * The leftmost item will be "0" aligned
     
    665666
    666667    /*
    667      * Make sure there is enough space for the letters + growing the 
    668      * selected item + extra space for the selected item.   
    669      */
    670     infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 
     668     * Make sure there is enough space for the letters + growing the
     669     * selected item + extra space for the selected item.
     670     */
     671    infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING +
    671672      SELECTED_TAB_OFFSET;
    672673  }
     
    677678     * Calculate the vertical position of the tab
    678679     */
    679     if (lStyle & TCS_BOTTOM) 
    680     {
    681       infoPtr->items[curItem].rect.bottom = clientRect.bottom - 
     680    if (lStyle & TCS_BOTTOM)
     681    {
     682      infoPtr->items[curItem].rect.bottom = clientRect.bottom -
    682683                                            SELECTED_TAB_OFFSET;
    683       infoPtr->items[curItem].rect.top = clientRect.bottom - 
     684      infoPtr->items[curItem].rect.top = clientRect.bottom -
    684685                                         infoPtr->tabHeight;
    685686    }
    686     else 
    687     {
    688       infoPtr->items[curItem].rect.top = clientRect.top + 
     687    else
     688    {
     689      infoPtr->items[curItem].rect.top = clientRect.top +
    689690                                         SELECTED_TAB_OFFSET;
    690       infoPtr->items[curItem].rect.bottom = clientRect.top + 
     691      infoPtr->items[curItem].rect.bottom = clientRect.top +
    691692                                            infoPtr->tabHeight;
    692693    }
     
    708709       * Calculate how wide the tab is depending on the text it contains
    709710       */
    710       GetTextExtentPoint32A(hdc, infoPtr->items[curItem].pszText, 
     711      GetTextExtentPoint32A(hdc, infoPtr->items[curItem].pszText,
    711712                            lstrlenA(infoPtr->items[curItem].pszText), &size);
    712      
     713
    713714      infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
    714715                                           size.cx + 2*HORIZONTAL_ITEM_PADDING;
     
    716717
    717718//    TRACE(tab, "TextSize: %i\n ", size.cx);
    718 //    TRACE(tab, "Rect: T %i, L %i, B %i, R %i\n", 
    719 //        infoPtr->items[curItem].rect.top,
    720 //        infoPtr->items[curItem].rect.left,
    721 //        infoPtr->items[curItem].rect.bottom,
    722 //        infoPtr->items[curItem].rect.right); 
     719//    TRACE(tab, "Rect: T %i, L %i, B %i, R %i\n",
     720//        infoPtr->items[curItem].rect.top,
     721//        infoPtr->items[curItem].rect.left,
     722//        infoPtr->items[curItem].rect.bottom,
     723//        infoPtr->items[curItem].rect.right);
    723724
    724725    /*
     
    735736   * Check if we need a scrolling control.
    736737   */
    737   infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) > 
     738  infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) >
    738739                             clientRect.right);
    739740
    740   TAB_SetupScrolling(hwnd, infoPtr, &clientRect);     
    741  
     741  TAB_SetupScrolling(hwnd, infoPtr, &clientRect);
     742
    742743  /*
    743744   * Cleanup
     
    751752 *
    752753 * This method is used to draw a single tab into the tab control.
    753  */         
     754 */
    754755static void TAB_DrawItem(
    755   HWND hwnd, 
    756   HDC  hdc, 
     756  HWND hwnd,
     757  HDC  hdc,
    757758  INT  iItem)
    758759{
     
    768769   */
    769770  isVisible = TAB_InternalGetItemRect(hwnd,
    770                                       infoPtr,
    771                                       iItem,
    772                                       &itemRect,
    773                                       &selectedRect);
     771                                      infoPtr,
     772                                      iItem,
     773                                      &itemRect,
     774                                      &selectedRect);
    774775
    775776  if (isVisible)
    776777  {
    777     HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));   
     778    HBRUSH hbr       = CreateSolidBrush (GetSysColor(COLOR_BTNFACE));
    778779    HPEN   hwPen     = GetSysColorPen (COLOR_3DHILIGHT);
    779780    HPEN   hbPen     = GetSysColorPen (COLOR_BTNSHADOW);
     
    782783    HPEN   holdPen;
    783784    INT    oldBkMode;
    784     INT    cx,cy; 
     785    INT    cx,cy;
    785786
    786787    if (lStyle & TCS_BUTTONS)
    787788    {
    788       /* 
     789      /*
    789790       * Get item rectangle.
    790791       */
     
    795796      if (iItem == infoPtr->iSelected)
    796797      {
    797         /* 
    798          * Background color. 
     798        /*
     799         * Background color.
    799800         */
    800801        if (!(lStyle & TCS_OWNERDRAWFIXED))
    801           hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));   
     802          hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));
    802803
    803804        /*
    804805         * Erase the background.
    805          */     
     806         */
    806807        FillRect(hdc, &r, hbr);
    807808
     
    819820        LineTo   (hdc, r.right, r.bottom);
    820821        LineTo   (hdc, r.right, r.top);
    821        
     822
    822823        /* shadow */
    823824        SelectObject(hdc, hbPen);
     
    829830        /*
    830831         * Erase the background.
    831          */     
     832         */
    832833        FillRect(hdc, &r, hbr);
    833834
     
    836837        LineTo   (hdc, r.left, r.top);
    837838        LineTo   (hdc, r.right, r.top);
    838        
     839
    839840        /* shadow */
    840841        SelectObject(hdc, hbPen);
     
    845846    else
    846847    {
    847       /* 
    848        * Background color. 
     848      /*
     849       * Background color.
    849850       */
    850       hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));   
     851      hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
    851852
    852853      /*
     
    861862      /*
    862863       * Erase the background.
    863        * This is necessary when drawing the selected item since it is larger 
    864        * than the others, it might overlap with stuff already drawn by the 
     864       * This is necessary when drawing the selected item since it is larger
     865       * than the others, it might overlap with stuff already drawn by the
    865866       * other tabs
    866        */     
     867       */
    867868      FillRect(hdc, &r, hbr);
    868869
     
    875876      r.right--;
    876877      r.bottom--;
    877      
     878
    878879      holdPen = SelectObject (hdc, hwPen);
    879880
    880       if (lStyle & TCS_BOTTOM) 
     881      if (lStyle & TCS_BOTTOM)
    881882      {
    882883        /* highlight */
     
    884885        LineTo   (hdc, r.left, r.bottom - ROUND_CORNER_SIZE);
    885886        LineTo   (hdc, r.left + ROUND_CORNER_SIZE, r.bottom);
    886        
     887
    887888        /* shadow */
    888889        SelectObject(hdc, hbPen);
     
    891892        LineTo  (hdc, r.right, r.top);
    892893      }
    893       else 
     894      else
    894895      {
    895896        /* highlight */
     
    898899        LineTo   (hdc, r.left + ROUND_CORNER_SIZE, r.top);
    899900        LineTo   (hdc, r.right - ROUND_CORNER_SIZE, r.top);
    900        
     901
    901902        /* shadow */
    902903        SelectObject(hdc, hbPen);
     
    905906      }
    906907    }
    907  
     908
    908909    /*
    909910     * Text pen
    910911     */
    911     SelectObject(hdc, hsdPen); 
    912 
    913     oldBkMode = SetBkMode(hdc, TRANSPARENT); 
     912    SelectObject(hdc, hsdPen);
     913
     914    oldBkMode = SetBkMode(hdc, TRANSPARENT);
    914915    SetTextColor (hdc, COLOR_BTNTEXT);
    915916
     
    922923     * Draw the icon.
    923924     */
    924     if (infoPtr->himl) 
    925     {
    926       ImageList_Draw (infoPtr->himl, iItem, hdc, 
    927                       r.left, r.top+1, ILD_NORMAL);
     925    if (infoPtr->himl)
     926    {
     927      ImageList_Draw (infoPtr->himl, iItem, hdc,
     928                      r.left, r.top+1, ILD_NORMAL);
    928929      ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
    929930      r.left+=cx;
     
    934935     */
    935936    DrawTextA(hdc,
    936               infoPtr->items[iItem].pszText,
    937               lstrlenA(infoPtr->items[iItem].pszText),
    938               &r,
    939               DT_LEFT|DT_SINGLELINE|DT_VCENTER);
     937              infoPtr->items[iItem].pszText,
     938              lstrlenA(infoPtr->items[iItem].pszText),
     939              &r,
     940              DT_LEFT|DT_SINGLELINE|DT_VCENTER);
    940941
    941942    /*
     
    943944     */
    944945    if (((lStyle & TCS_FOCUSNEVER) == 0) &&
    945         (GetFocus() == hwnd) &&
    946         (iItem == infoPtr->uFocus) )
     946        (GetFocus() == hwnd) &&
     947        (iItem == infoPtr->uFocus) )
    947948    {
    948949      InflateRect(&r, FOCUS_RECT_HOFFSET, FOCUS_RECT_VOFFSET);
     
    951952
    952953      MoveToEx (hdc, r.left,    r.top, NULL);
    953       LineTo   (hdc, r.right-1, r.top); 
     954      LineTo   (hdc, r.right-1, r.top);
    954955      LineTo   (hdc, r.right-1, r.bottom -1);
    955956      LineTo   (hdc, r.left,    r.bottom -1);
     
    970971 * This method is used to draw the raised border around the tab control
    971972 * "content" area.
    972  */         
     973 */
    973974static void TAB_DrawBorder (HWND hwnd, HDC hdc)
    974975{
     
    985986   * Adjust for the style
    986987   */
    987   if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     988  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    988989  {
    989990    rect.bottom -= infoPtr->tabHeight;
     
    10031004  /* highlight */
    10041005  htmPen = SelectObject (hdc, hwPen);
    1005  
     1006
    10061007  MoveToEx (hdc, rect.left, rect.bottom, NULL);
    1007   LineTo (hdc, rect.left, rect.top); 
     1008  LineTo (hdc, rect.left, rect.top);
    10081009  LineTo (hdc, rect.right, rect.top);
    10091010
     
    10261027 *
    10271028 * This method repaints the tab control..
    1028  */             
     1029 */
    10291030static void TAB_Refresh (HWND hwnd, HDC hdc)
    10301031{
     
    10401041  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS)
    10411042  {
    1042     for (i = 0; i < infoPtr->uNumItem; i++) 
    1043     {
    1044         TAB_DrawItem (hwnd, hdc, i);
     1043    for (i = 0; i < infoPtr->uNumItem; i++)
     1044    {
     1045        TAB_DrawItem (hwnd, hdc, i);
    10451046    }
    10461047  }
     
    10501051     * Draw all the non selected item first.
    10511052     */
    1052     for (i = 0; i < infoPtr->uNumItem; i++) 
     1053    for (i = 0; i < infoPtr->uNumItem; i++)
    10531054    {
    10541055      if (i != infoPtr->iSelected)
    1055         TAB_DrawItem (hwnd, hdc, i);
     1056        TAB_DrawItem (hwnd, hdc, i);
    10561057    }
    10571058
     
    10751076{
    10761077    TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1077  
     1078
    10781079  infoPtr->DoRedraw=(BOOL) wParam;
    10791080  return 0;
     
    10811082
    10821083static LRESULT TAB_EraseBackground(
    1083   HWND hwnd, 
     1084  HWND hwnd,
    10841085  HDC  givenDC)
    10851086{
     
    11351136  GetClientRect(infoPtr->hwndUpDown, &scrollerRect);
    11361137  visibleRect.right -= scrollerRect.right;
    1137  
     1138
    11381139  /*
    11391140   * Get the rectangle for the item
    11401141   */
    11411142  isVisible = TAB_InternalGetItemRect(hwnd,
    1142                                       infoPtr,
    1143                                       infoPtr->iSelected,
    1144                                       NULL,
    1145                                       &selectedRect);
     1143                                      infoPtr,
     1144                                      infoPtr->iSelected,
     1145                                      NULL,
     1146                                      &selectedRect);
    11461147
    11471148  /*
     
    11631164
    11641165  while ( (infoPtr->leftmostVisible < infoPtr->iSelected) &&
    1165           !isVisible)
     1166          !isVisible)
    11661167  {
    11671168    infoPtr->leftmostVisible++;
     
    11711172     */
    11721173    isVisible = TAB_InternalGetItemRect(hwnd,
    1173                                         infoPtr,
    1174                                         infoPtr->iSelected,
    1175                                         NULL,
    1176                                         &selectedRect);
     1174                                        infoPtr,
     1175                                        infoPtr->iSelected,
     1176                                        NULL,
     1177                                        &selectedRect);
    11771178
    11781179    /*
     
    11891190      pt2.x = selectedRect.right - 1;
    11901191      pt2.y = selectedRect.bottom - 1;
    1191      
     1192
    11921193      isVisible = PtInRect(&visibleRect, pt1) &&  PtInRect(&visibleRect, pt2);
    11931194    }
     
    12101211  GetClientRect(hwnd, &clientRect);
    12111212
    1212   if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 
     1213  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM)
    12131214  {
    12141215    clientRect.top = clientRect.bottom - (infoPtr->tabHeight + 1);
     
    12271228  HDC hdc;
    12281229  PAINTSTRUCT ps;
    1229    
     1230
    12301231  hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
    12311232  TAB_Refresh (hwnd, hdc);
    1232    
     1233
    12331234  if(!wParam)
    12341235    EndPaint (hwnd, &ps);
     
    12391240static LRESULT
    12401241TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    1241 {   
     1242{
    12421243  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    12431244  TCITEMA *pti;
    12441245  INT iItem, len;
    12451246  RECT rect;
    1246  
     1247
    12471248  GetClientRect (hwnd, &rect);
    12481249//  TRACE(tab, "Rect: %x T %i, L %i, B %i, R %i\n", hwnd,
    1249 //        rect.top, rect.left, rect.bottom, rect.right); 
    1250  
     1250//        rect.top, rect.left, rect.bottom, rect.right);
     1251
    12511252  pti = (TCITEMA *)lParam;
    12521253  iItem = (INT)wParam;
    1253  
     1254
    12541255  if (iItem < 0) return -1;
    12551256  if (iItem > infoPtr->uNumItem)
    12561257    iItem = infoPtr->uNumItem;
    1257  
     1258
    12581259  if (infoPtr->uNumItem == 0) {
    12591260    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
     
    12621263  else {
    12631264    TAB_ITEM *oldItems = infoPtr->items;
    1264    
     1265
    12651266    infoPtr->uNumItem++;
    12661267    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem);
    1267    
     1268
    12681269    /* pre insert copy */
    12691270    if (iItem > 0) {
    12701271      memcpy (&infoPtr->items[0], &oldItems[0],
    1271               iItem * sizeof(TAB_ITEM));
    1272     }
    1273    
     1272              iItem * sizeof(TAB_ITEM));
     1273    }
     1274
    12741275    /* post insert copy */
    12751276    if (iItem < infoPtr->uNumItem - 1) {
    12761277      memcpy (&infoPtr->items[iItem+1], &oldItems[iItem],
    1277               (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
    1278      
    1279     }
    1280    
     1278              (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM));
     1279
     1280    }
     1281
    12811282    COMCTL32_Free (oldItems);
    12821283  }
    1283  
     1284
    12841285  infoPtr->items[iItem].mask = pti->mask;
    12851286  if (pti->mask & TCIF_TEXT) {
     
    12891290    infoPtr->items[iItem].cchTextMax = pti->cchTextMax;
    12901291  }
    1291  
     1292
    12921293  if (pti->mask & TCIF_IMAGE)
    12931294    infoPtr->items[iItem].iImage = pti->iImage;
    1294  
     1295
    12951296  if (pti->mask & TCIF_PARAM)
    12961297    infoPtr->items[iItem].lParam = pti->lParam;
    1297  
     1298
    12981299  TAB_InvalidateTabArea(hwnd, infoPtr);
    1299  
     1300
    13001301//  TRACE(tab, "[%04x]: added item %d '%s'\n",
    1301 //      hwnd, iItem, infoPtr->items[iItem].pszText);
     1302//      hwnd, iItem, infoPtr->items[iItem].pszText);
    13021303
    13031304  TAB_SetItemBounds(hwnd);
     
    13051306}
    13061307
    1307 static LRESULT 
     1308static LRESULT
    13081309TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13091310{
     
    13221323}
    13231324
    1324 static LRESULT 
     1325static LRESULT
    13251326TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13261327{
    13271328  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1328   TCITEMA *tabItem; 
    1329   TAB_ITEM *wineItem; 
     1329  TCITEMA *tabItem;
     1330  TAB_ITEM *wineItem;
    13301331  INT    iItem,len;
    13311332
     
    13371338  wineItem=& infoPtr->items[iItem];
    13381339
    1339   if (tabItem->mask & TCIF_IMAGE) 
     1340  if (tabItem->mask & TCIF_IMAGE)
    13401341    wineItem->iImage=tabItem->iImage;
    13411342
    1342   if (tabItem->mask & TCIF_PARAM) 
     1343  if (tabItem->mask & TCIF_PARAM)
    13431344    wineItem->lParam=tabItem->lParam;
    13441345
    1345 //  if (tabItem->mask & TCIF_RTLREADING) 
     1346//  if (tabItem->mask & TCIF_RTLREADING)
    13461347//    FIXME (tab,"TCIF_RTLREADING\n");
    13471348
    1348   if (tabItem->mask & TCIF_STATE) 
     1349  if (tabItem->mask & TCIF_STATE)
    13491350    wineItem->dwState=tabItem->dwState;
    13501351
    13511352  if (tabItem->mask & TCIF_TEXT) {
    1352    len=lstrlenA (tabItem->pszText);
    1353    if (len>wineItem->cchTextMax) 
    1354      wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
     1353   len = lstrlenA (tabItem->pszText);
     1354   if (len>wineItem->cchTextMax)
     1355     wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, len+1);
    13551356   lstrcpynA (wineItem->pszText, tabItem->pszText, len);
    13561357  }
     
    13591360}
    13601361
    1361 static LRESULT 
     1362static LRESULT
    13621363TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13631364{
     
    13681369
    13691370
    1370 static LRESULT 
     1371static LRESULT
    13711372TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    13721373{
     
    13831384  wineItem=& infoPtr->items[iItem];
    13841385
    1385   if (tabItem->mask & TCIF_IMAGE) 
     1386  if (tabItem->mask & TCIF_IMAGE)
    13861387    tabItem->iImage=wineItem->iImage;
    13871388
    1388   if (tabItem->mask & TCIF_PARAM) 
     1389  if (tabItem->mask & TCIF_PARAM)
    13891390    tabItem->lParam=wineItem->lParam;
    13901391
    1391 //  if (tabItem->mask & TCIF_RTLREADING) 
     1392//  if (tabItem->mask & TCIF_RTLREADING)
    13921393//    FIXME (tab, "TCIF_RTLREADING\n");
    13931394
    1394   if (tabItem->mask & TCIF_STATE) 
     1395  if (tabItem->mask & TCIF_STATE)
    13951396    tabItem->dwState=wineItem->dwState;
    13961397
    1397   if (tabItem->mask & TCIF_TEXT) 
     1398  if (tabItem->mask & TCIF_TEXT)
    13981399   lstrcpynA (tabItem->pszText, wineItem->pszText, tabItem->cchTextMax);
    13991400
     
    14011402}
    14021403
    1403 static LRESULT 
     1404static LRESULT
    14041405TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    14051406{
     
    14111412  {
    14121413    TAB_ITEM *oldItems = infoPtr->items;
    1413    
     1414
    14141415    infoPtr->uNumItem--;
    14151416    infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem);
    1416    
    1417     if (iItem > 0) 
     1417
     1418    if (iItem > 0)
    14181419      memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM));
    1419    
    1420     if (iItem < infoPtr->uNumItem) 
     1420
     1421    if (iItem < infoPtr->uNumItem)
    14211422      memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1],
    14221423              (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM));
    1423    
     1424
    14241425    COMCTL32_Free (oldItems);
    14251426
     
    14291430    if ((iItem == infoPtr->iSelected) && (iItem > 0))
    14301431      infoPtr->iSelected--;
    1431      
     1432
    14321433    if (iItem < infoPtr->iSelected)
    14331434      infoPtr->iSelected--;
     
    14451446}
    14461447
    1447 static LRESULT 
     1448static LRESULT
    14481449TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
    14491450{
     
    14521453  COMCTL32_Free (infoPtr->items);
    14531454  infoPtr->uNumItem=0;
    1454  
     1455
    14551456  return TRUE;
    14561457}
     
    14711472{
    14721473  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1473  
     1474
    14741475//  TRACE (tab,"%x %lx\n",wParam, lParam);
    1475  
     1476
    14761477  infoPtr->hFont = (HFONT)wParam;
    1477  
     1478
    14781479  TAB_SetItemBounds(hwnd);
    14791480
     
    15251526    cx=LOWORD (lParam);
    15261527    cy=HIWORD (lParam);
    1527     if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 
     1528    if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE)
    15281529        uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
    15291530
     
    15481549
    15491550
    1550 static LRESULT 
     1551static LRESULT
    15511552TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    15521553{
     
    15591560
    15601561  SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
    1561    
     1562
    15621563  infoPtr->uNumItem        = 0;
    15631564  infoPtr->hFont           = 0;
    15641565  infoPtr->items           = 0;
    15651566  infoPtr->hcurArrow       = LoadCursorA (0, IDC_ARROWA);
    1566   infoPtr->iSelected       = 0; 
    1567   infoPtr->uFocus          = 0; 
     1567  infoPtr->iSelected       = 0;
     1568  infoPtr->uFocus          = 0;
    15681569  infoPtr->hwndToolTip     = 0;
    15691570  infoPtr->DoRedraw        = TRUE;
     
    15711572  infoPtr->hwndUpDown      = 0;
    15721573  infoPtr->leftmostVisible = 0;
    1573  
    1574 //  TRACE(tab, "Created tab control, hwnd [%04x]\n", hwnd); 
     1574
     1575//  TRACE(tab, "Created tab control, hwnd [%04x]\n", hwnd);
    15751576  if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_TOOLTIPS) {
    15761577    /* Create tooltip control */
    15771578    infoPtr->hwndToolTip =
    15781579      CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    1579                        CW_USEDEFAULT, CW_USEDEFAULT,
    1580                        CW_USEDEFAULT, CW_USEDEFAULT,
    1581                        hwnd, 0, 0, 0);
    1582    
     1580                       CW_USEDEFAULT, CW_USEDEFAULT,
     1581                       CW_USEDEFAULT, CW_USEDEFAULT,
     1582                       hwnd, 0, 0, 0);
     1583
    15831584    /* Send NM_TOOLTIPSCREATED notification */
    15841585    if (infoPtr->hwndToolTip) {
    15851586      NMTOOLTIPSCREATED nmttc;
    1586      
     1587
    15871588      nmttc.hdr.hwndFrom = hwnd;
    15881589      nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID);
    15891590      nmttc.hdr.code = NM_TOOLTIPSCREATED;
    15901591      nmttc.hwndToolTips = infoPtr->hwndToolTip;
    1591      
     1592
    15921593      SendMessageA (GetParent (hwnd), WM_NOTIFY,
    1593                     (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
    1594     }
    1595   } 
    1596    
     1594                    (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc);
     1595    }
     1596  }
     1597
    15971598  /*
    15981599   * We need to get text information so we need a DC and we need to select
    15991600   * a font.
    16001601   */
    1601   hdc = GetDC(hwnd); 
     1602  hdc = GetDC(hwnd);
    16021603  hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
    16031604
     
    16081609
    16091610  /*
    1610    * Make sure there is enough space for the letters + growing the 
    1611    * selected item + extra space for the selected item.   
    1612    */
    1613   infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 
     1611   * Make sure there is enough space for the letters + growing the
     1612   * selected item + extra space for the selected item.
     1613   */
     1614  infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING +
    16141615                       SELECTED_TAB_OFFSET;
    16151616
     
    16341635    for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) {
    16351636      if (infoPtr->items[iItem].pszText)
    1636         COMCTL32_Free (infoPtr->items[iItem].pszText);
     1637        COMCTL32_Free (infoPtr->items[iItem].pszText);
    16371638    }
    16381639    COMCTL32_Free (infoPtr->items);
    16391640  }
    1640  
    1641   if (infoPtr->hwndToolTip) 
     1641
     1642  if (infoPtr->hwndToolTip)
    16421643    DestroyWindow (infoPtr->hwndToolTip);
    1643  
     1644
    16441645  if (infoPtr->hwndUpDown)
    16451646    DestroyWindow(infoPtr->hwndUpDown);
     
    16561657    case TCM_GETIMAGELIST:
    16571658      return TAB_GetImageList (hwnd, wParam, lParam);
    1658      
     1659
    16591660    case TCM_SETIMAGELIST:
    16601661      return TAB_SetImageList (hwnd, wParam, lParam);
    1661      
     1662
    16621663    case TCM_GETITEMCOUNT:
    16631664      return TAB_GetItemCount (hwnd, wParam, lParam);
    1664      
     1665
    16651666    case TCM_GETITEMA:
    16661667      return TAB_GetItemA (hwnd, wParam, lParam);
    1667      
     1668
    16681669    case TCM_GETITEMW:
    16691670//      FIXME (tab, "Unimplemented msg TCM_GETITEMW\n");
    16701671      return 0;
    1671      
     1672
    16721673    case TCM_SETITEMA:
    16731674      return TAB_SetItemA (hwnd, wParam, lParam);
    1674      
     1675
    16751676    case TCM_SETITEMW:
    16761677//      FIXME (tab, "Unimplemented msg TCM_SETITEMW\n");
    16771678      return 0;
    1678      
     1679
    16791680    case TCM_DELETEITEM:
    16801681      return TAB_DeleteItem (hwnd, wParam, lParam);
    1681      
     1682
    16821683    case TCM_DELETEALLITEMS:
    16831684     return TAB_DeleteAllItems (hwnd, wParam, lParam);
    1684      
     1685
    16851686    case TCM_GETITEMRECT:
    16861687     return TAB_GetItemRect (hwnd, wParam, lParam);
    1687      
     1688
    16881689    case TCM_GETCURSEL:
    16891690      return TAB_GetCurSel (hwnd);
    1690      
     1691
    16911692    case TCM_HITTEST:
    16921693      return TAB_HitTest (hwnd, wParam, lParam);
    1693      
     1694
    16941695    case TCM_SETCURSEL:
    16951696      return TAB_SetCurSel (hwnd, wParam);
    1696      
     1697
    16971698    case TCM_INSERTITEMA:
    16981699      return TAB_InsertItem (hwnd, wParam, lParam);
    1699      
     1700
    17001701    case TCM_INSERTITEMW:
    17011702//      FIXME (tab, "Unimplemented msg TCM_INSERTITEM32W\n");
    17021703      return 0;
    1703      
     1704
    17041705    case TCM_SETITEMEXTRA:
    17051706//      FIXME (tab, "Unimplemented msg TCM_SETITEMEXTRA\n");
    17061707      return 0;
    1707      
     1708
    17081709    case TCM_ADJUSTRECT:
    17091710      return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam);
    1710      
     1711
    17111712    case TCM_SETITEMSIZE:
    17121713      return TAB_SetItemSize (hwnd, wParam, lParam);
    1713      
     1714
    17141715    case TCM_REMOVEIMAGE:
    17151716//      FIXME (tab, "Unimplemented msg TCM_REMOVEIMAGE\n");
    17161717      return 0;
    1717      
     1718
    17181719    case TCM_SETPADDING:
    17191720//      FIXME (tab, "Unimplemented msg TCM_SETPADDING\n");
    17201721      return 0;
    1721      
     1722
    17221723    case TCM_GETROWCOUNT:
    17231724//      FIXME (tab, "Unimplemented msg TCM_GETROWCOUNT\n");
     
    17351736//      FIXME (tab, "Unimplemented msg TCM_HIGHLIGHTITEM\n");
    17361737      return 0;
    1737      
     1738
    17381739    case TCM_GETTOOLTIPS:
    17391740      return TAB_GetToolTips (hwnd, wParam, lParam);
    1740      
     1741
    17411742    case TCM_SETTOOLTIPS:
    17421743      return TAB_SetToolTips (hwnd, wParam, lParam);
    1743      
     1744
    17441745    case TCM_GETCURFOCUS:
    17451746      return TAB_GetCurFocus (hwnd);
    1746      
     1747
    17471748    case TCM_SETCURFOCUS:
    17481749      return TAB_SetCurFocus (hwnd, wParam);
    1749      
     1750
    17501751    case TCM_SETMINTTABWIDTH:
    17511752//      FIXME (tab, "Unimplemented msg TCM_SETMINTTABWIDTH\n");
    17521753      return 0;
    1753      
     1754
    17541755    case TCM_DESELECTALL:
    17551756//      FIXME (tab, "Unimplemented msg TCM_DESELECTALL\n");
    17561757      return 0;
    1757      
     1758
    17581759    case TCM_GETEXTENDEDSTYLE:
    17591760//      FIXME (tab, "Unimplemented msg TCM_GETEXTENDEDSTYLE\n");
     
    17661767    case WM_GETFONT:
    17671768      return TAB_GetFont (hwnd, wParam, lParam);
    1768      
     1769
    17691770    case WM_SETFONT:
    17701771      return TAB_SetFont (hwnd, wParam, lParam);
    1771      
     1772
    17721773    case WM_CREATE:
    17731774      return TAB_Create (hwnd, wParam, lParam);
    1774      
     1775
    17751776    case WM_NCDESTROY:
    17761777      return TAB_Destroy (hwnd, wParam, lParam);
    1777      
     1778
    17781779    case WM_GETDLGCODE:
    17791780      return DLGC_WANTARROWS | DLGC_WANTCHARS;
    1780      
     1781
    17811782    case WM_LBUTTONDOWN:
    17821783      return TAB_LButtonDown (hwnd, wParam, lParam);
    1783      
     1784
    17841785    case WM_LBUTTONUP:
    17851786      return TAB_LButtonUp (hwnd, wParam, lParam);
    1786      
     1787
    17871788    case WM_RBUTTONDOWN:
    17881789      return TAB_RButtonDown (hwnd, wParam, lParam);
    1789      
     1790
    17901791    case WM_MOUSEMOVE:
    17911792      return TAB_MouseMove (hwnd, wParam, lParam);
    1792      
     1793
    17931794    case WM_ERASEBKGND:
    17941795      return TAB_EraseBackground (hwnd, (HDC)wParam);
     
    17991800    case WM_SIZE:
    18001801      return TAB_Size (hwnd, wParam, lParam);
    1801      
     1802
    18021803    case WM_SETREDRAW:
    18031804      return TAB_SetRedraw (hwnd, wParam);
     
    18051806    case WM_HSCROLL:
    18061807      return TAB_OnHScroll(hwnd, (int)LOWORD(wParam), (int)HIWORD(wParam), (HWND)lParam);
    1807      
     1808
    18081809    case WM_KILLFOCUS:
    18091810    case WM_SETFOCUS:
     
    18151816    default:
    18161817//      if (uMsg >= WM_USER)
    1817 //      ERR (tab, "unknown msg %04x wp=%08x lp=%08lx\n",
    1818 //           uMsg, wParam, lParam);
     1818//      ERR (tab, "unknown msg %04x wp=%08x lp=%08lx\n",
     1819//           uMsg, wParam, lParam);
    18191820      return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    18201821    }
     
    18391840  wndClass.hbrBackground = (HBRUSH)NULL;
    18401841  wndClass.lpszClassName = WC_TABCONTROLA;
    1841  
     1842
    18421843  RegisterClassA (&wndClass);
    18431844}
Note: See TracChangeset for help on using the changeset viewer.