Changeset 1058 for trunk/src


Ignore:
Timestamp:
Sep 26, 1999, 1:01:11 PM (26 years ago)
Author:
achimha
Message:

merged latest WINE 990923 changes

Location:
trunk/src/comctl32
Files:
9 edited

Legend:

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

    r925 r1058  
    1 /* $Id: comctl32.c,v 1.9 1999-09-13 18:49:02 cbratschi Exp $ */
     1/* $Id: comctl32.c,v 1.10 1999-09-26 11:01:08 achimha Exp $ */
    22/*
    33 * Win32 common controls implementation
     
    1111 *
    1212 */
     13
     14/* WINE 990923 level (commctrl.c) */
    1315
    1416#include "comctl32.h"
     
    167169            break;
    168170
     171        case WM_COMMAND :
     172//          TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
     173//                 wParam, lParam);
     174            /* WM_COMMAND is not invalid since it is documented
     175             * in the windows api reference. So don't output
     176             * any FIXME for WM_COMMAND
     177             */
     178//          WARN("We don't care about the WM_COMMAND\n");
     179            break;
     180
    169181        default:
    170182//          FIXME (commctrl, "Invalid Message 0x%x!\n", uMsg);
     
    646658    LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
    647659    UINT nSize, nColorTableSize;
    648     DWORD *pColorTable;
     660    RGBQUAD *pColorTable;
    649661    INT iColor, i, iMaps, nWidth, nHeight;
    650662    HDC hdcScreen;
    651663    HBITMAP hbm;
    652664    LPCOLORMAP sysColorMap;
     665    COLORREF cRef;
    653666    COLORMAP internalColorMap[4] =
    654667        {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
     
    685698    RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
    686699
    687     pColorTable = (DWORD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
     700    pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
    688701
    689702    for (iColor = 0; iColor < nColorTableSize; iColor++) {
    690703        for (i = 0; i < iMaps; i++) {
    691             if (pColorTable[iColor] == sysColorMap[i].from) {
     704            cRef = RGB(pColorTable[iColor].rgbRed,
     705                       pColorTable[iColor].rgbGreen,
     706                       pColorTable[iColor].rgbBlue);
     707            if ( cRef  == sysColorMap[i].from) {
    692708#if 0
    693709                if (wFlags & CBS_MASKED) {
     
    697713                else
    698714#endif
    699                     pColorTable[iColor] = sysColorMap[i].to;
     715                    pColorTable[iColor].rgbBlue  = GetBValue(sysColorMap[i].to);
     716                    pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
     717                    pColorTable[iColor].rgbRed   = GetRValue(sysColorMap[i].to);
    700718                break;
    701719            }
    702720        }
    703721    }
    704 
    705722    nWidth  = (INT)lpBitmapInfo->biWidth;
    706723    nHeight = (INT)lpBitmapInfo->biHeight;
  • trunk/src/comctl32/comctl32.h

    r496 r1058  
    1 /* $Id: comctl32.h,v 1.7 1999-08-14 16:13:10 cbratschi Exp $ */
     1/* $Id: comctl32.h,v 1.8 1999-09-26 11:01:08 achimha Exp $ */
    22/*
    33 * Win32 common controls implementation
     
    1111 *
    1212 */
     13
     14/* Status: WINE 990923 */
    1315
    1416#ifndef _H_COMCTL32
     
    5557#define IDC_TABCONTROL   12320
    5658#define IDC_APPLY_BUTTON 12321
     59#define IDC_BACK_BUTTON  12323
     60#define IDC_NEXT_BUTTON  12324
     61#define IDC_FINISH_BUTTON 12325
     62#define IDC_SUNKEN_LINE   12326
    5763
    5864/* Toolbar customization dialog */
  • trunk/src/comctl32/comctl32undoc.c

    r722 r1058  
    1 /* $Id: comctl32undoc.c,v 1.11 1999-08-28 09:25:56 achimha Exp $ */
     1/* $Id: comctl32undoc.c,v 1.12 1999-09-26 11:01:08 achimha Exp $ */
    22/*
    33 * Undocumented functions from COMCTL32.DLL
     
    1212 */
    1313
    14 /* WINE 990815 level */
     14/* WINE 990923 level */
    1515
    1616/* CB: todo
     
    689689            /* resize the block of memory */
    690690            nNewItems =
    691                 hdsa->nGrow * ((INT)((nIndex - 1) / hdsa->nGrow) + 1);
     691                hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
    692692            nSize = hdsa->nItemSize * nNewItems;
    693693
     
    11951195            /* resize the block of memory */
    11961196            INT nNewItems =
    1197                 hdpa->nGrow * ((INT)((i - 1) / hdpa->nGrow) + 1);
     1197                hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
    11981198            INT nSize = nNewItems * sizeof(LPVOID);
    11991199
  • trunk/src/comctl32/imagelist.c

    r496 r1058  
    1 /* $Id: imagelist.c,v 1.6 1999-08-14 16:13:11 cbratschi Exp $ */
     1/* $Id: imagelist.c,v 1.7 1999-09-26 11:01:09 achimha Exp $ */
    22/*
    33 *  ImageList implementation
     
    3030*/
    3131
     32/* WINE 990923 level */
     33
    3234/* This must be defined because the HIMAGELIST type is just a pointer
    3335 * to the _IMAGELIST data structure. But M$ does not want us to know
     
    206208    HBITMAP hOldBitmapImage, hOldBitmapMask;
    207209    HIMAGELIST himlLocal = pimldp->himl;
     210    COLORREF oldBkColor, oldFgColor;
    208211
    209212    bUseCustomBackground = (himlLocal->clrBk != CLR_NONE);
     
    238241        || bBlendFlag)
    239242    {
     243        /* to obtain a transparent look, background color should be set
     244           to white and foreground color to black when blting the
     245           monochrome mask. */
     246        oldBkColor = SetBkColor(pimldp->hdcDst, RGB(0xff, 0xff, 0xff));
     247        oldFgColor = SetTextColor(pimldp->hdcDst, RGB(0, 0, 0));
     248
    240249        BitBlt(pimldp->hdcDst,
    241250            pimldp->x, pimldp->y, cx, cy,
     
    249258            himlLocal->cx * pimldp->i, 0,
    250259            SRCPAINT);
     260
     261        SetBkColor(pimldp->hdcDst, oldBkColor);
     262        SetTextColor(pimldp->hdcDst, oldFgColor);
    251263    }
    252264    /* Draw the image when no Background is specified
     
    889901//    TRACE(imagelist, "Image: %d Bits per Pixel\n", himl->uBitsPixel);
    890902
    891     himl->hbmImage =
    892         CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
     903    if (himl->cMaxImage > 0) {
     904        himl->hbmImage =
     905          CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
    893906                        1, himl->uBitsPixel, NULL);
    894     if (himl->hbmImage == 0) {
    895 //        ERR(imagelist, "Error creating image bitmap!\n");
    896         return NULL;
    897     }
    898 
    899     if (himl->flags & ILC_MASK) {
     907        if (himl->hbmImage == 0) {
     908//          ERR("Error creating image bitmap!\n");
     909            return NULL;
     910        }
     911    }
     912    else
     913        himl->hbmImage = 0;
     914   
     915    if ( (himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) {
    900916        himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy,
    901917                                        1, 1, NULL);
     
    21072123    HDC     hdcImageList, hdcImage;
    21082124    INT     nIndex;
     2125    HICON   hBestFitIcon;
    21092126    HBITMAP hbmOldSrc, hbmOldDst;
    21102127    ICONINFO  ii;
     
    21182135        return -1;
    21192136
    2120     GetIconInfo (hIcon, &ii);
     2137    hBestFitIcon = CopyImage(
     2138        hIcon, IMAGE_ICON,
     2139        himl->cx, himl->cy,
     2140        LR_COPYFROMRESOURCE);
     2141
     2142    GetIconInfo (hBestFitIcon, &ii);
    21212143//    if (ii.hbmMask == 0)
    21222144//      ERR (imagelist, "no mask!\n");
     
    21622184    SelectObject (hdcImageList, hbmOldDst);
    21632185
     2186    if(hBestFitIcon)
     2187        DestroyIcon(hBestFitIcon);
    21642188    if (hdcImageList)
    21652189        DeleteDC (hdcImageList);
  • trunk/src/comctl32/listview.c

    r496 r1058  
    4343 *   LISTVIEW_Update : not completed
    4444 */
     45
     46/* WINE 990923 level */
    4547
    4648#include <string.h>
     
    35763578  HDC hdc;
    35773579  HFONT hOldFont;
    3578   INT nMaxWidth;
     3580  INT nLeftPos;
    35793581  INT nLabelWidth;
    35803582  TEXTMETRICA tm;
     
    36823684          {
    36833685            bResult = TRUE;
    3684             nMaxWidth = lprc->left = ptItem.x + ptOrigin.x;
     3686            nLeftPos = lprc->left = ptItem.x + ptOrigin.x;
    36853687            lprc->top = ptItem.y + ptOrigin.y;
    36863688            lprc->bottom = lprc->top + infoPtr->nItemHeight;
     
    36973699
    36983700            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
    3699             if (lprc->left + nLabelWidth < nMaxWidth + infoPtr->nItemWidth)
     3701            if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
    37003702            {
    37013703              lprc->right = lprc->left + nLabelWidth;
     
    37033705            else
    37043706            {
    3705               lprc->right = nMaxWidth + infoPtr->nItemWidth;
     3707              lprc->right = nLeftPos + infoPtr->nItemWidth;
    37063708            }
    37073709          }
     
    37103712        {
    37113713          bResult = TRUE;
    3712           lprc->left = ptItem.x;
     3714          nLeftPos = lprc->left = ptItem.x;
    37133715          lprc->top = ptItem.y;
    37143716          lprc->bottom = lprc->top + infoPtr->nItemHeight;
     
    37243726          }
    37253727
    3726           lprc->right = lprc->left + LISTVIEW_GetLabelWidth(hwnd, nItem);
     3728          nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     3729          if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
     3730          {
     3731            lprc->right = lprc->left + nLabelWidth;
     3732          }
     3733          else
     3734          {
     3735            lprc->right = nLeftPos + infoPtr->nItemWidth;
     3736          }
    37273737        }
    37283738        break;
     
    37773787          }
    37783788
    3779           lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
     3789            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     3790            if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)
     3791            {
     3792              lprc->right += nLabelWidth;
     3793            }
     3794            else
     3795            {
     3796              lprc->right = lprc->left + infoPtr->nItemWidth;
     3797            }
    37803798        }
    37813799        break;
     
    38013819          {
    38023820            bResult = TRUE;
    3803             lprc->left = ptItem.x + ptOrigin.x;
     3821            nLeftPos= lprc->left = ptItem.x + ptOrigin.x; 
    38043822            lprc->top = ptItem.y + ptOrigin.y;
    38053823            lprc->bottom = lprc->top + infoPtr->nItemHeight;
     
    38173835            }
    38183836
    3819             lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
     3837          nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     3838          if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)
     3839          {
     3840            lprc->right += nLabelWidth;
     3841          }
     3842          else
     3843          {
     3844            lprc->right = lprc->left + infoPtr->nItemWidth;
     3845          }
    38203846          }
    38213847        }
     
    38233849        {
    38243850          bResult = TRUE;
    3825           lprc->left = ptItem.x;
     3851          nLeftPos = lprc->left = ptItem.x;
    38263852          lprc->top = ptItem.y;
    38273853          lprc->bottom = lprc->top + infoPtr->nItemHeight;
     
    38393865          }
    38403866
    3841           lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
     3867          nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     3868          if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
     3869          {
     3870            lprc->right += nLabelWidth;
     3871          }
     3872          else
     3873          {
     3874            lprc->right = nLeftPos + infoPtr->nItemWidth;
     3875          }
    38423876        }
    38433877        break;
     
    38603894 *   FAILURE : zero
    38613895 */
    3862 static INT LISTVIEW_GetLabelWidth(HWND hwnd, INT nItem)
     3896INT LISTVIEW_GetLabelWidth(HWND hwnd, INT nItem)
    38633897{
    38643898  CHAR szDispText[DISP_TEXT_SIZE];
     
    38923926 * Horizontal + vertical spacing
    38933927 */
    3894 static LRESULT LISTVIEW_GetItemSpacing(HWND hwnd, BOOL bSmall)
     3928LRESULT LISTVIEW_GetItemSpacing(HWND hwnd, BOOL bSmall)
    38953929{
    38963930  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     
    39223956 * State specified by the mask.
    39233957 */
    3924 static LRESULT LISTVIEW_GetItemState(HWND hwnd, INT nItem, UINT uMask)
     3958LRESULT LISTVIEW_GetItemState(HWND hwnd, INT nItem, UINT uMask)
    39253959{
    39263960  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     
    39563990 *   FAILURE : 0
    39573991 */
    3958 static LRESULT LISTVIEW_GetItemTextA(HWND hwnd, INT nItem, LPLVITEMA lpLVItem)
     3992LRESULT LISTVIEW_GetItemTextA(HWND hwnd, INT nItem, LPLVITEMA lpLVItem)
    39593993{
    39603994  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     
    45094543}
    45104544
    4511 /* LISTVIEW_InsertColumnW  */
     4545static LRESULT LISTVIEW_InsertColumnW(HWND hwnd, INT nColumn,
     4546                                      LPLVCOLUMNW lpColumn)
     4547{
     4548  LVCOLUMNA     lvca;
     4549  LRESULT               lres;
     4550     
     4551  memcpy(&lvca,lpColumn,sizeof(lvca));
     4552//AH: todo
     4553//  if (lpColumn->mask & LVCF_TEXT)
     4554//    lvca.pszText = HEAP_strdupWtoA(GetProcessHeap(),0,lpColumn->pszText);
     4555  lres = LISTVIEW_InsertColumnA(hwnd,nColumn,&lvca);
     4556  if (lpColumn->mask & LVCF_TEXT)
     4557    HeapFree(GetProcessHeap(),0,lvca.pszText);
     4558  return lres;
     4559}
    45124560
    45134561/***
     
    46094657}
    46104658
    4611 /* LISTVIEW_InsertItemW */
     4659static LRESULT LISTVIEW_InsertItemW(HWND hwnd, LPLVITEMW lpLVItem) {
     4660  LVITEMA lvia;
     4661  LRESULT lres;
     4662
     4663  memcpy(&lvia,lpLVItem,sizeof(LVITEMA));
     4664  if (lvia.mask & LVIF_TEXT) {
     4665    if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW)
     4666      lvia.pszText = LPSTR_TEXTCALLBACKA;
     4667//AH: todo
     4668//    else
     4669//      lvia.pszText = HEAP_strdupWtoA(GetProcessHeap(),0,lpLVItem->pszText);
     4670  }
     4671  lres = LISTVIEW_InsertItemA(hwnd, &lvia);
     4672  if (lvia.mask & LVIF_TEXT) {
     4673    if (lpLVItem->pszText != LPSTR_TEXTCALLBACKW)
     4674      HeapFree(GetProcessHeap(),0,lvia.pszText);
     4675  }
     4676  return lres;
     4677}
    46124678
    46134679/***
     
    63236389  infoPtr->bFocus = TRUE;
    63246390
     6391  InvalidateRect(hwnd, NULL, TRUE);
     6392  UpdateWindow(hwnd);
     6393
    63256394  return 0;
    63266395}
     
    67226791
    67236792  case LVM_INSERTCOLUMNA:
    6724     return LISTVIEW_InsertColumnA(hwnd, (INT)wParam,
    6725                                     (LPLVCOLUMNA)lParam);
    6726 
    6727 /*      case LVM_INSERTCOLUMNW: */
     6793    return LISTVIEW_InsertColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);
     6794
     6795  case LVM_INSERTCOLUMNW:
     6796    return LISTVIEW_InsertColumnW(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam);
    67286797
    67296798  case LVM_INSERTITEMA:
    67306799    return LISTVIEW_InsertItemA(hwnd, (LPLVITEMA)lParam);
    67316800
    6732 /*      case LVM_INSERTITEMW: */
     6801  case LVM_INSERTITEMW:
     6802    return LISTVIEW_InsertItemW(hwnd, (LPLVITEMW)lParam);
    67336803
    67346804  case LVM_REDRAWITEMS:
     
    68276897
    68286898  case WM_GETDLGCODE:
    6829     return DLGC_WANTTAB | DLGC_WANTARROWS;
     6899    return DLGC_WANTCHARS | DLGC_WANTARROWS;
    68306900
    68316901  case WM_GETFONT:
  • trunk/src/comctl32/propsheet.c

    r722 r1058  
    1 /* $Id: propsheet.c,v 1.8 1999-08-28 09:25:56 achimha Exp $ */
     1/* $Id: propsheet.c,v 1.9 1999-09-26 11:01:10 achimha Exp $ */
    22/*
    33 * Property Sheets
     
    99 *
    1010 * TODO:
    11  *   - Modeless mode
    12  *   - Wizard mode
     11 *   - Tab order
    1312 *   - Unicode property sheets
    1413 */
    1514
    16 /* WINE 990815 level */
     15/* WINE 990923 level */
    1716
    1817/* CB: Odin problems:
     
    108107static BOOL PROPSHEET_ShowPage(HWND hwndDlg, int index, PropSheetInfo * psInfo);
    109108static PADDING_INFO PROPSHEET_GetPaddingInfo(HWND hwndDlg);
     109static BOOL PROPSHEET_Back(HWND hwndDlg);
     110static BOOL PROPSHEET_Next(HWND hwndDlg);
     111static BOOL PROPSHEET_Finish(HWND hwndDlg);
    110112static BOOL PROPSHEET_Apply(HWND hwndDlg);
    111113static void PROPSHEET_Cancel(HWND hwndDlg);
     
    114116static void PROPSHEET_UnChanged(HWND hwndDlg, HWND hwndCleanPage);
    115117static void PROPSHEET_PressButton(HWND hwndDlg, int buttonID);
     118static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText);
    116119static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText);
    117120static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
     
    130133static void PROPSHEET_CleanUp();
    131134static int PROPSHEET_GetPageIndex(HPROPSHEETPAGE hpage, PropSheetInfo* psInfo);
     135static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags);
     136static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg);
    132137
    133138BOOL WINAPI
     
    282287  p += lstrlenW((LPCWSTR)p) + 1;
    283288
     289  if (dwFlags & PSP_USETITLE)
     290  {
     291//AH: todo
     292//    psInfo->proppage[index].pszText = HEAP_strdupAtoW(GetProcessHeap(),
     293//                                                      0,
     294//                                                      lppsp->pszTitle);
     295  }
     296
    284297  /*
    285298   * Build the image list for icons
     
    311324 * Creates the actual property sheet.
    312325 */
     326
     327//AH: WINE 990923 not merged due to changes from CB
     328
    313329BOOL PROPSHEET_CreateDialog(PropSheetInfo* psInfo)
    314330{
     
    407423
    408424/******************************************************************************
     425 *            PROPSHEET_IsTooSmallWizard
     426 *
     427 * Verify that the default property sheet is big enough.
     428 */
     429static BOOL PROPSHEET_IsTooSmallWizard(HWND hwndDlg, PropSheetInfo* psInfo)
     430{
     431  RECT rcSheetRect, rcPage, rcLine, rcSheetClient;
     432  HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
     433  PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg);
     434
     435  GetClientRect(hwndDlg, &rcSheetClient);
     436  GetWindowRect(hwndDlg, &rcSheetRect);
     437  GetWindowRect(hwndLine, &rcLine);
     438
     439  /* Remove the space below the sunken line */
     440  rcSheetClient.bottom -= (rcSheetRect.bottom - rcLine.top);
     441
     442  /* Remove the buffer zone all around the edge */
     443  rcSheetClient.bottom -= (padding.y * 2);
     444  rcSheetClient.right -= (padding.x * 2);
     445
     446  /*
     447   * Biggest page size.
     448   */
     449  rcPage.left   = psInfo->x;
     450  rcPage.top    = psInfo->y;
     451  rcPage.right  = psInfo->width;
     452  rcPage.bottom = psInfo->height;
     453
     454  MapDialogRect(hwndDlg, &rcPage);
     455//  TRACE("biggest page %d %d %d %d\n", rcPage.left, rcPage.top,
     456//        rcPage.right, rcPage.bottom);
     457
     458  if (rcPage.right > rcSheetClient.right)
     459    return TRUE;
     460
     461  if (rcPage.bottom > rcSheetClient.bottom)
     462    return TRUE;
     463
     464  return FALSE;
     465}
     466
     467/******************************************************************************
    409468 *            PROPSHEET_AdjustSize
    410469 *
     
    453512  rc.right += ((padding.x * 2) + tabOffsetX);
    454513  rc.bottom += (buttonHeight + (3 * padding.y) + tabOffsetY);
     514
     515  /*
     516   * Resize the property sheet.
     517   */
     518  SetWindowPos(hwndDlg, 0, 0, 0, rc.right, rc.bottom,
     519               SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
     520
     521  return TRUE;
     522}
     523
     524/******************************************************************************
     525 *            PROPSHEET_AdjustSizeWizard
     526 *
     527 * Resizes the property sheet to fit the largest page.
     528 */
     529static BOOL PROPSHEET_AdjustSizeWizard(HWND hwndDlg, PropSheetInfo* psInfo)
     530{
     531  HWND hwndButton = GetDlgItem(hwndDlg, IDCANCEL);
     532  HWND hwndLine = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
     533  RECT rc;
     534  int buttonHeight, lineHeight;
     535  PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndDlg);
     536
     537  /* Get the height of buttons */
     538  GetClientRect(hwndButton, &rc);
     539  buttonHeight = rc.bottom;
     540
     541  GetClientRect(hwndLine, &rc);
     542  lineHeight = rc.bottom;
     543
     544  /*
     545   * Biggest page size.
     546   */
     547  rc.left   = psInfo->x;
     548  rc.top    = psInfo->y;
     549  rc.right  = psInfo->width;
     550  rc.bottom = psInfo->height;
     551
     552  MapDialogRect(hwndDlg, &rc);
     553
     554//  TRACE("Biggest page %d %d %d %d\n", rc.left, rc.top, rc.right, rc.bottom);
     555
     556  /* Make room */
     557  rc.right += (padding.x * 2);
     558  rc.bottom += (buttonHeight + (5 * padding.y) + lineHeight);
    455559
    456560  /*
     
    559663
    560664/******************************************************************************
     665 *            PROPSHEET_AdjustButtonsWizard
     666 *
     667 * Adjusts the buttons' positions.
     668 */
     669static BOOL PROPSHEET_AdjustButtonsWizard(HWND hwndParent,
     670                                          PropSheetInfo* psInfo)
     671{
     672  HWND hwndButton = GetDlgItem(hwndParent, IDCANCEL);
     673  HWND hwndLine = GetDlgItem(hwndParent, IDC_SUNKEN_LINE);
     674  RECT rcSheet;
     675  int x, y;
     676  int num_buttons = 3;
     677  int buttonWidth, buttonHeight, lineHeight, lineWidth;
     678  PADDING_INFO padding = PROPSHEET_GetPaddingInfoWizard(hwndParent);
     679
     680  if (psInfo->hasHelp)
     681    num_buttons++;
     682
     683  /*
     684   * Obtain the size of the buttons.
     685   */
     686  GetClientRect(hwndButton, &rcSheet);
     687  buttonWidth = rcSheet.right;
     688  buttonHeight = rcSheet.bottom;
     689
     690  GetClientRect(hwndLine, &rcSheet);
     691  lineHeight = rcSheet.bottom;
     692
     693  /*
     694   * Get the size of the property sheet.
     695   */
     696  GetClientRect(hwndParent, &rcSheet);
     697
     698  /*
     699   * All buttons will be at this y coordinate.
     700   */
     701  y = rcSheet.bottom - (padding.y + buttonHeight);
     702
     703  /*
     704   * Position the Next and the Finish buttons.
     705   */
     706  hwndButton = GetDlgItem(hwndParent, IDC_NEXT_BUTTON);
     707
     708  x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 1));
     709
     710  SetWindowPos(hwndButton, 0, x, y, 0, 0,
     711               SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     712
     713  hwndButton = GetDlgItem(hwndParent, IDC_FINISH_BUTTON);
     714
     715  SetWindowPos(hwndButton, 0, x, y, 0, 0,
     716               SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     717
     718  ShowWindow(hwndButton, SW_HIDE);
     719
     720  /*
     721   * Position the Back button.
     722   */
     723  hwndButton = GetDlgItem(hwndParent, IDC_BACK_BUTTON);
     724
     725  x -= buttonWidth;
     726
     727  SetWindowPos(hwndButton, 0, x, y, 0, 0,
     728               SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     729
     730  /*
     731   * Position the Cancel button.
     732   */
     733  hwndButton = GetDlgItem(hwndParent, IDCANCEL);
     734
     735  x = rcSheet.right - ((padding.x + buttonWidth) * (num_buttons - 2));
     736
     737  SetWindowPos(hwndButton, 0, x, y, 0, 0,
     738               SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     739
     740  /*
     741   * Position Help button.
     742   */
     743  hwndButton = GetDlgItem(hwndParent, IDHELP);
     744
     745  if (psInfo->hasHelp)
     746  {
     747    x = rcSheet.right - (padding.x + buttonWidth);
     748
     749    SetWindowPos(hwndButton, 0, x, y, 0, 0,
     750                 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     751  }
     752  else
     753    ShowWindow(hwndButton, SW_HIDE);
     754
     755  /*
     756   * Position and resize the sunken line.
     757   */
     758  x = padding.x;
     759  y = rcSheet.bottom - ((padding.y * 2) + buttonHeight + lineHeight);
     760
     761  GetClientRect(hwndParent, &rcSheet);
     762  lineWidth = rcSheet.right - (padding.x * 2);
     763
     764  SetWindowPos(hwndLine, 0, x, y, lineWidth, 2,
     765               SWP_NOZORDER | SWP_NOACTIVATE);
     766
     767  return TRUE;
     768}
     769
     770/******************************************************************************
    561771 *            PROPSHEET_GetPaddingInfo
    562772 *
     
    579789  padding.x = tl.x;
    580790  padding.y = tl.y;
     791
     792  return padding;
     793}
     794
     795/******************************************************************************
     796 *            PROPSHEET_GetPaddingInfoWizard
     797 *
     798 * Returns the layout information.
     799 * Horizontal spacing is the distance between the Cancel and Help buttons.
     800 * Vertical spacing is the distance between the line and the buttons.
     801 */
     802static PADDING_INFO PROPSHEET_GetPaddingInfoWizard(HWND hwndDlg)
     803{
     804  PADDING_INFO padding;
     805  RECT rc;
     806  HWND hwndControl;
     807  POINT ptHelp, ptCancel, ptLine;
     808
     809  /* Help button */
     810  hwndControl = GetDlgItem(hwndDlg, IDHELP);
     811  GetWindowRect(hwndControl, &rc);
     812
     813  ptHelp.x = rc.left;
     814  ptHelp.y = rc.top;
     815
     816  ScreenToClient(hwndDlg, &ptHelp);
     817
     818  /* Cancel button */
     819  hwndControl = GetDlgItem(hwndDlg, IDCANCEL);
     820  GetWindowRect(hwndControl, &rc);
     821
     822  ptCancel.x = rc.right;
     823  ptCancel.y = rc.top;
     824
     825  ScreenToClient(hwndDlg, &ptCancel);
     826
     827  /* Line */
     828  hwndControl = GetDlgItem(hwndDlg, IDC_SUNKEN_LINE);
     829  GetWindowRect(hwndControl, &rc);
     830
     831  ptLine.x = 0;
     832  ptLine.y = rc.bottom;
     833
     834  ScreenToClient(hwndDlg, &ptLine);
     835
     836  padding.x = ptHelp.x - ptCancel.x;
     837  padding.y = ptHelp.y - ptLine.y;
    581838
    582839  return padding;
     
    640897  RECT rc;
    641898  PropPageInfo* ppInfo = psInfo->proppage;
    642   PADDING_INFO padding = PROPSHEET_GetPaddingInfo(hwndParent);
    643   HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
     899  PADDING_INFO padding;
     900  HWND hwndAfter;
    644901
    645902//  TRACE(propsheet, "index %d\n", index);
     
    696953  MapDialogRect(hwndParent, &rc);
    697954
    698   /*
    699    * Ask the Tab control to fit this page in.
    700    */
    701   SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
    702 
    703   SetWindowPos(hwndPage, HWND_TOP,
     955  if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
     956  {
     957    GetWindowRect(hwndParent, &rc);
     958    padding = PROPSHEET_GetPaddingInfoWizard(hwndParent);
     959    hwndAfter = hwndParent;
     960  }
     961  else
     962  {
     963    /*
     964     * Ask the Tab control to fit this page in.
     965     */
     966
     967    HWND hwndTabCtrl = GetDlgItem(hwndParent, IDC_TABCONTROL);
     968    SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
     969    padding = PROPSHEET_GetPaddingInfo(hwndParent);
     970    hwndAfter = HWND_TOP;
     971  }
     972
     973  SetWindowPos(hwndPage, hwndAfter,
    704974               rc.left + padding.x,
    705975               rc.top + padding.y,
     
    7471017
    7481018  psInfo->active_page = index;
     1019
     1020  return TRUE;
     1021}
     1022
     1023/******************************************************************************
     1024 *            PROPSHEET_Back
     1025 */
     1026static BOOL PROPSHEET_Back(HWND hwndDlg)
     1027{
     1028  BOOL res;
     1029  NMHDR hdr;
     1030  HWND hwndPage;
     1031  HWND hwndBack = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
     1032  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
     1033                                                    PropSheetInfoStr);
     1034
     1035  hdr.code = PSN_WIZBACK;
     1036
     1037  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
     1038
     1039  if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr) == -1)
     1040    return FALSE;
     1041
     1042  res = PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page - 1, 0);
     1043
     1044  /* if we went to page 0, disable Back button */
     1045  if (res && (psInfo->active_page == 0))
     1046    EnableWindow(hwndBack, FALSE);
     1047
     1048  return TRUE;
     1049}
     1050
     1051/******************************************************************************
     1052 *            PROPSHEET_Next
     1053 */
     1054static BOOL PROPSHEET_Next(HWND hwndDlg)
     1055{
     1056  NMHDR hdr;
     1057  HWND hwndPage;
     1058  LRESULT msgResult = 0;
     1059  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
     1060                                                    PropSheetInfoStr);
     1061
     1062  hdr.code = PSN_WIZNEXT;
     1063
     1064  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
     1065
     1066  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
     1067
     1068//  TRACE("msg result %ld\n", msgResult);
     1069
     1070  if (msgResult == -1)
     1071    return FALSE;
     1072
     1073  PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page + 1, 0);
     1074
     1075  return TRUE;
     1076}
     1077
     1078/******************************************************************************
     1079 *            PROPSHEET_Finish
     1080 */
     1081static BOOL PROPSHEET_Finish(HWND hwndDlg)
     1082{
     1083  NMHDR hdr;
     1084  HWND hwndPage;
     1085  LRESULT msgResult = 0;
     1086  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
     1087                                                    PropSheetInfoStr);
     1088
     1089  hdr.code = PSN_WIZFINISH;
     1090
     1091  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
     1092
     1093  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
     1094
     1095//  TRACE("msg result %ld\n", msgResult);
     1096
     1097  if (msgResult != 0)
     1098    return FALSE;
     1099
     1100  if (psInfo->isModeless)
     1101    psInfo->active_page = -1;
     1102  else
     1103    EndDialog(hwndDlg, TRUE);
    7491104
    7501105  return TRUE;
     
    9031258      break;
    9041259    case PSBTN_BACK:
    905 //      FIXME(propsheet, "Wizard mode not implemented.\n");
     1260      PROPSHEET_Back(hwndDlg);
    9061261      break;
    9071262    case PSBTN_CANCEL:
     
    9091264      break;
    9101265    case PSBTN_FINISH:
    911 //      FIXME(propsheet, "Wizard mode not implemented.\n");
     1266      PROPSHEET_Finish(hwndDlg);
    9121267      break;
    9131268    case PSBTN_HELP:
     
    9151270      break;
    9161271    case PSBTN_NEXT:
    917 //      FIXME(propsheet, "Wizard mode not implemented.\n");
     1272      PROPSHEET_Next(hwndDlg);
    9181273      break;
    9191274    case PSBTN_OK:
     
    10161371  else
    10171372    SetWindowTextA(hwndDlg, lpszText);
     1373}
     1374
     1375/******************************************************************************
     1376 *            PROPSHEET_SetFinishTextA
     1377 */
     1378static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText)
     1379{
     1380  HWND hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
     1381
     1382  /* Set text, show and enable the Finish button */
     1383  SetWindowTextA(hwndButton, lpszText);
     1384  ShowWindow(hwndButton, SW_SHOW);
     1385  EnableWindow(hwndButton, TRUE);
     1386
     1387  /* Make it default pushbutton */
     1388  SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
     1389
     1390  /* Hide Back button */
     1391  hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
     1392  ShowWindow(hwndButton, SW_HIDE);
     1393
     1394  /* Hide Next button */
     1395  hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
     1396  ShowWindow(hwndButton, SW_HIDE);
    10181397}
    10191398
     
    11961575
    11971576/******************************************************************************
     1577 *            PROPSHEET_SetWizButtons
     1578 *
     1579 * This code will work if (and assumes that) the Next button is on top of the
     1580 * Finish button. ie. Finish comes after Next in the Z order.
     1581 * This means make sure the dialog template reflects this.
     1582 *
     1583 */
     1584static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags)
     1585{
     1586  HWND hwndButton;
     1587
     1588//  TRACE("%ld\n", dwFlags);
     1589
     1590  if (dwFlags & PSWIZB_BACK)
     1591  {
     1592    hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
     1593    EnableWindow(hwndButton, TRUE);
     1594  }
     1595
     1596  if (dwFlags & PSWIZB_NEXT)
     1597  {
     1598    /* Hide the Finish button */
     1599    hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
     1600    ShowWindow(hwndButton, SW_HIDE);
     1601
     1602    /* Show and enable the Next button */
     1603    hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
     1604   
     1605    ShowWindow(hwndButton, SW_SHOW);
     1606    EnableWindow(hwndButton, TRUE);
     1607
     1608    /* Set the Next button as the default pushbutton  */
     1609    SendMessageA(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
     1610  }
     1611
     1612  if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH))
     1613  {
     1614    /* Hide the Next button */
     1615    hwndButton = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
     1616    ShowWindow(hwndButton, SW_HIDE);
     1617
     1618    /* Show the Finish button */
     1619    hwndButton = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
     1620    ShowWindow(hwndButton, SW_SHOW);
     1621
     1622    if (dwFlags & PSWIZB_FINISH)
     1623      EnableWindow(hwndButton, TRUE);
     1624    else
     1625      EnableWindow(hwndButton, FALSE);
     1626
     1627    /* Set the Finish button as the default pushbutton  */
     1628    SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
     1629  }
     1630}
     1631
     1632/******************************************************************************
    11981633 *            PROPSHEET_GetPageIndex
    11991634 *
     
    13221757      LPCPROPSHEETPAGEA ppshpage;
    13231758
     1759      /*
     1760       * Small icon in the title bar.
     1761       */
     1762      if ((psInfo->ppshheader->dwFlags & PSH_USEICONID) ||
     1763          (psInfo->ppshheader->dwFlags & PSH_USEHICON))
     1764      {
     1765        HICON hIcon;
     1766        int icon_cx = GetSystemMetrics(SM_CXSMICON);
     1767        int icon_cy = GetSystemMetrics(SM_CYSMICON);
     1768
     1769        if (psInfo->ppshheader->dwFlags & PSH_USEICONID)
     1770          hIcon = LoadImageA(psInfo->ppshheader->hInstance,
     1771                             psInfo->ppshheader->u1.pszIcon,
     1772                             IMAGE_ICON,
     1773                             icon_cx, icon_cy,
     1774                             LR_DEFAULTCOLOR);
     1775        else
     1776          hIcon = psInfo->ppshheader->u1.hIcon;
     1777
     1778        SendMessageA(hwnd, WM_SETICON, 0, hIcon);
     1779      }
     1780     
     1781      if (psInfo->ppshheader->dwFlags & PSH_USEHICON)
     1782        SendMessageA(hwnd, WM_SETICON, 0, psInfo->ppshheader->u1.hIcon);
     1783
    13241784      psInfo->strPropertiesFor = strCaption;
    13251785
    13261786      GetWindowTextA(hwnd, psInfo->strPropertiesFor, MAX_CAPTION_LENGTH);
    13271787
    1328       PROPSHEET_CreateTabControl(hwnd, psInfo);
    1329 
    1330       if (PROPSHEET_IsTooSmall(hwnd, psInfo))
     1788      if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
    13311789      {
    1332         PROPSHEET_AdjustSize(hwnd, psInfo);
    1333         PROPSHEET_AdjustButtons(hwnd, psInfo);
     1790        HWND hwndBack = GetDlgItem(hwnd, IDC_BACK_BUTTON);
     1791
     1792        if (PROPSHEET_IsTooSmallWizard(hwnd, psInfo))
     1793        {
     1794          PROPSHEET_AdjustSizeWizard(hwnd, psInfo);
     1795          PROPSHEET_AdjustButtonsWizard(hwnd, psInfo);
     1796        }
     1797
     1798        /* Disable Back button if we start at page 0 */
     1799        if (psInfo->active_page == 0)
     1800          EnableWindow(hwndBack, FALSE);
    13341801      }
    1335 
    1336       ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page);
     1802      else
     1803      {
     1804        PROPSHEET_CreateTabControl(hwnd, psInfo);
     1805
     1806        if (PROPSHEET_IsTooSmall(hwnd, psInfo))
     1807        {
     1808          PROPSHEET_AdjustSize(hwnd, psInfo);
     1809          PROPSHEET_AdjustButtons(hwnd, psInfo);
     1810        }
     1811      }
     1812
     1813      ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page);     
    13371814      PROPSHEET_CreatePage(hwnd, psInfo->active_page, psInfo, ppshpage, TRUE);
    1338       SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0);
     1815
     1816      if (!(psInfo->ppshheader->dwFlags & PSH_WIZARD))
     1817        SendMessageA(hwndTabCtrl, TCM_SETCURSEL, psInfo->active_page, 0);
    13391818
    13401819      SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
     
    13931872        }
    13941873
     1874        case IDC_BACK_BUTTON:
     1875          PROPSHEET_Back(hwnd);
     1876          break;
     1877
     1878        case IDC_NEXT_BUTTON:
     1879          PROPSHEET_Next(hwnd);
     1880          break;
     1881
     1882        case IDC_FINISH_BUTTON:
     1883          PROPSHEET_Finish(hwnd);
     1884          break;
     1885
    13951886        case IDCANCEL:
    13961887          PROPSHEET_Cancel(hwnd);
     
    14841975    case PSM_REBOOTSYSTEM:
    14851976    {
    1486       PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
     1977      PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd, 
    14871978                                                        PropSheetInfoStr);
    14881979
     
    15232014    case PSM_ISDIALOGMESSAGE:
    15242015    {
    1525 //      FIXME (propsheet, "Unimplemented msg PSM_ISDIALOGMESSAGE\n");
     2016//      FIXME("Unimplemented msg PSM_ISDIALOGMESSAGE\n");
    15262017      return 0;
    15272018    }
     
    15312022      return TRUE;
    15322023
     2024    case PSM_SETFINISHTEXTA:
     2025      PROPSHEET_SetFinishTextA(hwnd, (LPCSTR) lParam);       
     2026      return TRUE;
     2027
     2028    case PSM_SETWIZBUTTONS:
     2029      PROPSHEET_SetWizButtons(hwnd, (DWORD)lParam);
     2030      return TRUE;
     2031
    15332032    case PSM_SETTITLEW:
    1534 //        FIXME (propsheet, "Unimplemented msg PSM_SETTITLE32W\n");
    1535         return 0;
    1536     case PSM_SETWIZBUTTONS:
    1537 //        FIXME (propsheet, "Unimplemented msg PSM_SETWIZBUTTONS\n");
     2033//        FIXME("Unimplemented msg PSM_SETTITLE32W\n");
    15382034        return 0;
    15392035    case PSM_SETCURSELID:
    1540 //        FIXME (propsheet, "Unimplemented msg PSM_SETCURSELID\n");
    1541         return 0;
    1542     case PSM_SETFINISHTEXTA:
    1543 //        FIXME (propsheet, "Unimplemented msg PSM_SETFINISHTEXT32A\n");
     2036//        FIXME("Unimplemented msg PSM_SETCURSELID\n");
    15442037        return 0;
    15452038    case PSM_SETFINISHTEXTW:
    1546 //        FIXME (propsheet, "Unimplemented msg PSM_SETFINISHTEXT32W\n");
     2039//        FIXME("Unimplemented msg PSM_SETFINISHTEXT32W\n");
    15472040        return 0;
    15482041
  • trunk/src/comctl32/status.c

    r496 r1058  
    1 /* $Id: status.c,v 1.10 1999-08-14 16:13:12 cbratschi Exp $ */
     1/* $Id: status.c,v 1.11 1999-09-26 11:01:10 achimha Exp $ */
    22/*
    33 * Interface code to StatusWindow widget/control
     
    88 * Copyright 1999 Christoph Bratschi
    99 */
     10
     11/* WINE 990923 level */
    1012
    1113#include "winbase.h"
     
    838840    LPCREATESTRUCTA lpCreate = (LPCREATESTRUCTA)lParam;
    839841    NONCLIENTMETRICSA nclm;
    840     RECT        rect;
    841     int         width, len;
    842     HDC hdc;
     842    RECT        rect;
     843    int         width, len;
     844    HDC hdc;
    843845    STATUSWINDOWINFO *self;
    844846
     
    873875
    874876    if (IsWindowUnicode (hwnd)) {
    875         self->bUnicode = TRUE;
    876         len = lstrlenW ((LPCWSTR)lpCreate->lpszName);
    877         if (len) {
    878             self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    879             lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName);
    880         }
     877        self->bUnicode = TRUE;
     878        if (lpCreate->lpszName &&
     879            (len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) {
     880            self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     881            lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName);
     882        }
    881883    }
    882884    else {
    883         len = lstrlenA ((LPCSTR)lpCreate->lpszName);
    884         if (len) {
    885             self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
    886             lstrcpyAtoW (self->parts[0].text, (char*)lpCreate->lpszName);
    887         }
    888     }
    889 
    890     hdc = GetDC(hwnd);
    891     if (hdc) {
    892         TEXTMETRICA tm;
    893         HFONT hOldFont;
    894 
    895         hOldFont = SelectObject (hdc,self->hDefaultFont);
    896         GetTextMetricsA(hdc, &tm);
    897         self->textHeight = tm.tmHeight;
    898         SelectObject (hdc, hOldFont);
    899         ReleaseDC(hwnd, hdc);
     885        if (lpCreate->lpszName &&
     886            (len = lstrlenA ((LPCSTR)lpCreate->lpszName))) {
     887            self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
     888            lstrcpyAtoW (self->parts[0].text, (LPCSTR)lpCreate->lpszName);
     889        }
     890    }
     891
     892    if ((hdc = GetDC (0))) {
     893        TEXTMETRICA tm;
     894        HFONT hOldFont;
     895
     896        hOldFont = SelectObject (hdc,self->hDefaultFont);
     897        GetTextMetricsA(hdc, &tm);
     898        self->textHeight = tm.tmHeight;
     899        SelectObject (hdc, hOldFont);
     900        ReleaseDC(0, hdc);
    900901    }
    901902
    902903    if (GetWindowLongA (hwnd, GWL_STYLE) & SBT_TOOLTIPS) {
    903         self->hwndToolTip =
    904             CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
    905                                CW_USEDEFAULT, CW_USEDEFAULT,
    906                                CW_USEDEFAULT, CW_USEDEFAULT,
    907                              hwnd, 0,
    908                              GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
    909 
    910         if (self->hwndToolTip) {
    911             NMTOOLTIPSCREATED nmttc;
    912 
    913             nmttc.hdr.hwndFrom = hwnd;
    914             nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
    915             nmttc.hdr.code = NM_TOOLTIPSCREATED;
    916             nmttc.hwndToolTips = self->hwndToolTip;
    917 
    918             SendMessageA (GetParent (hwnd), WM_NOTIFY,
    919                             (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
    920         }
     904        self->hwndToolTip =
     905            CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
     906                               CW_USEDEFAULT, CW_USEDEFAULT,
     907                               CW_USEDEFAULT, CW_USEDEFAULT,
     908                             hwnd, 0,
     909                             GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     910
     911        if (self->hwndToolTip) {
     912            NMTOOLTIPSCREATED nmttc;
     913
     914            nmttc.hdr.hwndFrom = hwnd;
     915            nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
     916            nmttc.hdr.code = NM_TOOLTIPSCREATED;
     917            nmttc.hwndToolTips = self->hwndToolTip;
     918
     919            SendMessageA (GetParent (hwnd), WM_NOTIFY,
     920                            (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
     921        }
    921922    }
    922923
    923924    GetClientRect (GetParent (hwnd), &rect);
    924925    width = rect.right - rect.left;
    925     self->height = self->textHeight+2*VERT_BORDER+2*VERT_SPACE;
     926    self->height = self->textHeight + 4 + VERT_BORDER;
    926927    MoveWindow (hwnd, lpCreate->x, lpCreate->y-1,
    927                   width, self->height, FALSE);
     928                  width, self->height, FALSE);
    928929    STATUSBAR_SetPartBounds (hwnd);
    929930
  • trunk/src/comctl32/tab.c

    r722 r1058  
    1 /* $Id: tab.c,v 1.12 1999-08-28 09:25:56 achimha Exp $ */
     1/* $Id: tab.c,v 1.13 1999-09-26 11:01:11 achimha Exp $ */
    22/*
    33 * Tab control
     
    1515 */
    1616
    17 /* WINE 990815 level */
     17/* WINE 990823 level */
    1818
    1919#include <string.h>
     
    130130  INT iItem=(INT) wParam;
    131131
    132   if ((iItem < 0) || (iItem > infoPtr->uNumItem)) return 0;
     132  if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0;
    133133
    134134  infoPtr->uFocus=iItem;
     
    13011301    infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
    13021302    infoPtr->uNumItem++;
     1303    infoPtr->iSelected = 0;
    13031304  }
    13041305  else {
     
    13201321
    13211322    }
     1323
     1324    if (iItem <= infoPtr->iSelected)
     1325      infoPtr->iSelected++;
    13221326
    13231327    COMCTL32_Free (oldItems);
     
    15301534  tabItem=(LPTCITEMA) lParam;
    15311535//  TRACE (tab,"\n");
    1532   if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE;
     1536  if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE;
    15331537
    15341538  wineItem=& infoPtr->items[iItem];
     
    16161620      infoPtr->iSelected--;
    16171621
     1622    if (infoPtr->uNumItem == 0)
     1623      infoPtr->iSelected = -1;
     1624
    16181625    /*
    16191626     * Reposition and repaint tabs.
     
    16341641
    16351642  COMCTL32_Free (infoPtr->items);
    1636   infoPtr->uNumItem=0;
     1643  infoPtr->uNumItem = 0;
     1644  infoPtr->iSelected = -1;
    16371645
    16381646  return TRUE;
     
    17471755  infoPtr->items           = 0;
    17481756  infoPtr->hcurArrow       = LoadCursorA (0, IDC_ARROWA);
    1749   infoPtr->iSelected       = 0;
     1757  infoPtr->iSelected       = -1;
    17501758  infoPtr->uFocus          = 0;
    17511759  infoPtr->hwndToolTip     = 0;
  • trunk/src/comctl32/tooltips.c

    r496 r1058  
    1 /* $Id: tooltips.c,v 1.13 1999-08-14 16:13:15 cbratschi Exp $ */
     1/* $Id: tooltips.c,v 1.14 1999-09-26 11:01:11 achimha Exp $ */
    22/*
    33 * Tool tip control
     
    2121 - CS_SAVEBITS: window movements are slow, bug in Open32?
    2222*/
     23
     24/* WINE 990923 level */
    2325
    2426#include <string.h>
     
    834836    toolPtr = &infoPtr->tools[nTool];
    835837    if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    836         if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
     838        if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
     839             (HIWORD((INT)toolPtr->lpszText) != 0) )
    837840            COMCTL32_Free (toolPtr->lpszText);
    838841    }
     
    891894    toolPtr = &infoPtr->tools[nTool];
    892895    if ((toolPtr->hinst) && (toolPtr->lpszText)) {
    893         if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW)
     896        if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
     897             (HIWORD((INT)toolPtr->lpszText) != 0) )
    894898            COMCTL32_Free (toolPtr->lpszText);
    895899    }
     
    15731577            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    15741578        else {
    1575             if (toolPtr->lpszText) {
     1579            if ( (toolPtr->lpszText) &&
     1580                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
    15761581                COMCTL32_Free (toolPtr->lpszText);
    15771582                toolPtr->lpszText = NULL;
     
    16271632            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    16281633        else {
    1629             if (toolPtr->lpszText) {
     1634            if ( (toolPtr->lpszText) &&
     1635                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
    16301636                COMCTL32_Free (toolPtr->lpszText);
    16311637                toolPtr->lpszText = NULL;
     
    17111717
    17121718
    1713 static LRESULT
    17141719TOOLTIPS_UpdateTipTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
    17151720{
     
    17191724    INT nTool;
    17201725
    1721     if (lpToolInfo == NULL) return 0;
    1722     if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) return FALSE;
    1723 
    1724     nTool = TOOLTIPS_GetToolFromInfoA(infoPtr,lpToolInfo);
     1726    if (lpToolInfo == NULL)
     1727        return 0;
     1728    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA)
     1729        return FALSE;
     1730
     1731    nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo);
    17251732    if (nTool == -1) return 0;
    17261733
    1727 //    TRACE (tooltips, "tool %d\n", nTool);
     1734//    TRACE("tool %d\n", nTool);
    17281735
    17291736    toolPtr = &infoPtr->tools[nTool];
     
    17321739    toolPtr->hinst  = lpToolInfo->hinst;
    17331740
    1734     if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0))
    1735     {
    1736       toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
    1737     } else if (lpToolInfo->lpszText)
    1738     {
    1739       if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1740       else
    1741       {
    1742         if (toolPtr->lpszText)
    1743         {
    1744           COMCTL32_Free(toolPtr->lpszText);
    1745           toolPtr->lpszText = NULL;
    1746         }
    1747         if (lpToolInfo->lpszText)
    1748         {
    1749           INT len = lstrlenA(lpToolInfo->lpszText);
    1750           toolPtr->lpszText = COMCTL32_Alloc((len+1)*sizeof(WCHAR));
    1751           lstrcpyAtoW(toolPtr->lpszText,lpToolInfo->lpszText);
    1752         }
    1753       }
     1741    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
     1742        toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText;
     1743    }
     1744    else if (lpToolInfo->lpszText) {
     1745        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA)
     1746            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1747        else {
     1748            if ( (toolPtr->lpszText) &&
     1749                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
     1750                COMCTL32_Free (toolPtr->lpszText);
     1751                toolPtr->lpszText = NULL;
     1752            }
     1753            if (lpToolInfo->lpszText) {
     1754                INT len = lstrlenA (lpToolInfo->lpszText);
     1755                toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1756                lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText);
     1757            }
     1758        }
    17541759    }
    17551760
    17561761    /* force repaint */
    1757     if (infoPtr->bActive) TOOLTIPS_Show(hwnd,infoPtr);
    1758     else if (infoPtr->bTrackActive) TOOLTIPS_TrackShow(hwnd,infoPtr);
     1762    if (infoPtr->bActive)
     1763        TOOLTIPS_Show (hwnd, infoPtr);
     1764    else if (infoPtr->bTrackActive)
     1765        TOOLTIPS_TrackShow (hwnd, infoPtr);
    17591766
    17601767    return 0;
     
    17711778
    17721779    if (lpToolInfo == NULL)
    1773         return 0;
     1780        return 0;
    17741781    if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW)
    1775         return FALSE;
     1782        return FALSE;
    17761783
    17771784    nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo);
    17781785    if (nTool == -1)
    1779         return 0;
    1780 
    1781 //    TRACE (tooltips, "tool %d\n", nTool);
     1786        return 0;
     1787
     1788//    TRACE("tool %d\n", nTool);
    17821789
    17831790    toolPtr = &infoPtr->tools[nTool];
     
    17871794
    17881795    if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){
    1789         toolPtr->lpszText = lpToolInfo->lpszText;
     1796        toolPtr->lpszText = lpToolInfo->lpszText;
    17901797    }
    17911798    else if (lpToolInfo->lpszText) {
    1792         if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
    1793             toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
    1794         else {
    1795             if (toolPtr->lpszText) {
    1796                 COMCTL32_Free (toolPtr->lpszText);
    1797                 toolPtr->lpszText = NULL;
    1798             }
    1799             if (lpToolInfo->lpszText) {
    1800                 INT len = lstrlenW (lpToolInfo->lpszText);
    1801                 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
    1802                 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
    1803             }
    1804         }
     1799        if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW)
     1800            toolPtr->lpszText = LPSTR_TEXTCALLBACKW;
     1801        else {
     1802            if ( (toolPtr->lpszText)  &&
     1803                 (HIWORD((INT)toolPtr->lpszText) != 0) ) {
     1804                COMCTL32_Free (toolPtr->lpszText);
     1805                toolPtr->lpszText = NULL;
     1806            }
     1807            if (lpToolInfo->lpszText) {
     1808                INT len = lstrlenW (lpToolInfo->lpszText);
     1809                toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
     1810                lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText);
     1811            }
     1812        }
    18051813    }
    18061814
    18071815    /* force repaint */
    18081816    if (infoPtr->bActive)
    1809         TOOLTIPS_Show (hwnd, infoPtr);
     1817        TOOLTIPS_Show (hwnd, infoPtr);
    18101818    else if (infoPtr->bTrackActive)
    1811         TOOLTIPS_TrackShow (hwnd, infoPtr);
     1819        TOOLTIPS_TrackShow (hwnd, infoPtr);
    18121820
    18131821    return 0;
     
    18821890
    18831891    /* free tools */
    1884     if (infoPtr->tools)
    1885     {
    1886       for (i = 0;i < infoPtr->uNumTools;i++)
    1887       {
    1888         toolPtr = &infoPtr->tools[i];
    1889         if ((toolPtr->hinst) && (toolPtr->lpszText))
    1890         {
    1891           if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(toolPtr->lpszText);
    1892         }
    1893 
    1894         /* remove subclassing */
    1895         TOOLTIPS_Desubclass(toolPtr);
    1896 
     1892    if (infoPtr->tools) {
     1893        for (i = 0; i < infoPtr->uNumTools; i++) {
     1894            toolPtr = &infoPtr->tools[i];
     1895            if ((toolPtr->hinst) && (toolPtr->lpszText)) {
     1896                if ( (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) &&
     1897                     (HIWORD((INT)toolPtr->lpszText) != 0) )
     1898                {
     1899                    COMCTL32_Free (toolPtr->lpszText);
     1900                    toolPtr->lpszText = NULL;
     1901                }
     1902            }
     1903
     1904            /* remove subclassing */
     1905            if (toolPtr->uFlags & TTF_SUBCLASS) {
     1906                LPTT_SUBCLASS_INFO lpttsi;
     1907
     1908                if (toolPtr->uFlags & TTF_IDISHWND)
     1909                    lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     1910                else
     1911                    lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass);
     1912
     1913                if (lpttsi) {
     1914                    SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC,
     1915                                      (LONG)lpttsi->wpOrigProc);
     1916                    RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass);
     1917                    COMCTL32_Free (&lpttsi);
     1918                }
     1919            }
    18971920      }
    18981921      COMCTL32_Free (infoPtr->tools);
Note: See TracChangeset for help on using the changeset viewer.