Ignore:
Timestamp:
Aug 28, 1999, 11:25:56 AM (26 years ago)
Author:
achimha
Message:

merged with latest WINE changes

File:
1 edited

Legend:

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

    r603 r722  
    1 /* $Id: tab.c,v 1.11 1999-08-21 12:10:02 cbratschi Exp $ */
     1/* $Id: tab.c,v 1.12 1999-08-28 09:25:56 achimha Exp $ */
    22/*
    33 * Tab control
     
    1212 *  Image list support
    1313 *  Multiline support
     14 *  Unicode support
    1415 */
     16
     17/* WINE 990815 level */
    1518
    1619#include <string.h>
     
    643646   * a font.
    644647   */
    645   hdc = GetDC(hwnd);
    646 
     648  hdc = GetDC(hwnd); 
     649   
    647650  hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
    648651  hOldFont = SelectObject (hdc, hFont);
     
    653656   */
    654657  GetClientRect(hwnd, &clientRect);
    655 
     658 
    656659  /*
    657660   * The leftmost item will be "0" aligned
     
    661664  if (!((lStyle & TCS_FIXEDWIDTH) || (lStyle & TCS_OWNERDRAWFIXED)))
    662665  {
     666    int item_height;
     667    int icon_height = 0;
     668
    663669    /*
    664670     * Use the current font to determine the height of a tab.
     
    667673
    668674    /*
    669      * Make sure there is enough space for the letters + growing the
    670      * selected item + extra space for the selected item.
    671      */
    672     infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING +
     675     * Get the icon height
     676     */
     677    if (infoPtr->himl)
     678      ImageList_GetIconSize(infoPtr->himl, 0, &icon_height);
     679
     680    /*
     681     * Take the highest between font or icon
     682     */
     683    if (fontMetrics.tmHeight > icon_height)
     684      item_height = fontMetrics.tmHeight;
     685    else
     686      item_height = icon_height;
     687
     688    /*
     689     * Make sure there is enough space for the letters + icon + growing the
     690     * selected item + extra space for the selected item.   
     691     */
     692    infoPtr->tabHeight = item_height + 2*VERTICAL_ITEM_PADDING + 
    673693      SELECTED_TAB_OFFSET;
    674694  }
     
    679699     * Calculate the vertical position of the tab
    680700     */
    681     if (lStyle & TCS_BOTTOM)
    682     {
    683       infoPtr->items[curItem].rect.bottom = clientRect.bottom -
     701    if (lStyle & TCS_BOTTOM) 
     702    {
     703      infoPtr->items[curItem].rect.bottom = clientRect.bottom - 
    684704                                            SELECTED_TAB_OFFSET;
    685       infoPtr->items[curItem].rect.top = clientRect.bottom -
     705      infoPtr->items[curItem].rect.top = clientRect.bottom - 
    686706                                         infoPtr->tabHeight;
    687707    }
    688     else
    689     {
    690       infoPtr->items[curItem].rect.top = clientRect.top +
     708    else 
     709    {
     710      infoPtr->items[curItem].rect.top = clientRect.top + 
    691711                                         SELECTED_TAB_OFFSET;
    692       infoPtr->items[curItem].rect.bottom = clientRect.top +
     712      infoPtr->items[curItem].rect.bottom = clientRect.top + 
    693713                                            infoPtr->tabHeight;
    694714    }
     
    707727    else
    708728    {
     729      int icon_width  = 0;
     730      int num = 2;
     731
    709732      /*
    710733       * Calculate how wide the tab is depending on the text it contains
    711734       */
    712       GetTextExtentPoint32W(hdc, infoPtr->items[curItem].pszText,
    713                             lstrlenW(infoPtr->items[curItem].pszText), &size);
     735      GetTextExtentPoint32A(hdc, infoPtr->items[curItem].pszText,
     736                            lstrlenA(infoPtr->items[curItem].pszText), &size);
     737
     738      /*
     739       * Add the icon width
     740       */
     741      if (infoPtr->himl)
     742      {
     743        ImageList_GetIconSize(infoPtr->himl, &icon_width, 0);
     744        num++;
     745      }
    714746
    715747      infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left +
    716                                            size.cx + 2*HORIZONTAL_ITEM_PADDING;
    717     }
    718 
    719 //    TRACE(tab, "TextSize: %i\n ", size.cx);
    720 //    TRACE(tab, "Rect: T %i, L %i, B %i, R %i\n",
    721 //        infoPtr->items[curItem].rect.top,
    722 //        infoPtr->items[curItem].rect.left,
    723 //        infoPtr->items[curItem].rect.bottom,
    724 //        infoPtr->items[curItem].rect.right);
     748                                           size.cx + icon_width +
     749                                           num*HORIZONTAL_ITEM_PADDING;
     750    }
     751
     752//    TRACE("TextSize: %i\n ", size.cx);
     753//    TRACE("Rect: T %i, L %i, B %i, R %i\n",
     754//        infoPtr->items[curItem].rect.top,
     755//        infoPtr->items[curItem].rect.left,
     756//        infoPtr->items[curItem].rect.bottom,
     757//        infoPtr->items[curItem].rect.right); 
    725758
    726759    /*
     
    737770   * Check if we need a scrolling control.
    738771   */
    739   infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) >
     772  infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) > 
    740773                             clientRect.right);
    741774
    742   TAB_SetupScrolling(hwnd, infoPtr, &clientRect);
    743 
     775  TAB_SetupScrolling(hwnd, infoPtr, &clientRect);     
     776 
    744777  /*
    745778   * Cleanup
     
    933966                      r.left, r.top+1, ILD_NORMAL);
    934967      ImageList_GetIconSize (infoPtr->himl, &cx, &cy);
    935       r.left+=cx;
     968      r.left+=(cx + HORIZONTAL_ITEM_PADDING);
    936969    }
    937970
     
    13981431}
    13991432
    1400 static LRESULT
     1433static LRESULT 
    14011434TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    14021435{
    14031436  TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
    1404   TCITEMA *tabItem;
    1405   TAB_ITEM *wineItem;
     1437  TCITEMA *tabItem; 
     1438  TAB_ITEM *wineItem; 
    14061439  INT    iItem,len;
    14071440
    14081441  iItem=(INT) wParam;
    14091442  tabItem=(LPTCITEMA ) lParam;
    1410 //  TRACE (tab,"%d %p\n",iItem, tabItem);
     1443//  TRACE("%d %p\n",iItem, tabItem);
    14111444  if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE;
    14121445
     
    14191452    wineItem->lParam=tabItem->lParam;
    14201453
    1421 //  if (tabItem->mask & TCIF_RTLREADING)
    1422 //    FIXME (tab,"TCIF_RTLREADING\n");
    1423 
    1424   if (tabItem->mask & TCIF_STATE)
     1454//  if (tabItem->mask & TCIF_RTLREADING) 
     1455//    FIXME("TCIF_RTLREADING\n");
     1456
     1457  if (tabItem->mask & TCIF_STATE) 
    14251458    wineItem->dwState=tabItem->dwState;
    14261459
    14271460  if (tabItem->mask & TCIF_TEXT) {
    1428    len = lstrlenA (tabItem->pszText);
    1429    if (len>wineItem->cchTextMax)
    1430      wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, (len+1)*sizeof(WCHAR));
    1431    lstrcpyAtoW (wineItem->pszText, tabItem->pszText);
    1432   }
     1461   len=lstrlenA (tabItem->pszText);
     1462   if (len>wineItem->cchTextMax)
     1463     wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1);
     1464   lstrcpyA (wineItem->pszText, tabItem->pszText);
     1465  }
     1466
     1467  /*
     1468   * Update and repaint tabs.
     1469   */
     1470  TAB_SetItemBounds(hwnd);
     1471  TAB_InvalidateTabArea(hwnd,infoPtr);
    14331472
    14341473  return TRUE;
Note: See TracChangeset for help on using the changeset viewer.