Changeset 500 for trunk/src


Ignore:
Timestamp:
Aug 15, 1999, 9:11:02 PM (26 years ago)
Author:
cbratschi
Message:

wine-990731 update

Location:
trunk/src/user32/new
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/button.cpp

    r402 r500  
    1 /* $Id: button.cpp,v 1.10 1999-07-27 16:14:22 cbratschi Exp $ */
     1/* $Id: button.cpp,v 1.11 1999-08-15 19:11:00 cbratschi Exp $ */
    22/* File: button.cpp -- Button type widgets
    33 *
     
    3131static void OB_Paint(HWND hwnd,HDC hDC,WORD action);
    3232static void BUTTON_CheckAutoRadioButton(HWND hwnd);
     33static void BUTTON_DrawPushButton(HWND hwnd,HDC hDC,WORD action,BOOL pushedState);
    3334static LRESULT BUTTON_LButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam);
    3435
     
    181182{
    182183  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    183 
    184   switch(dwStyle & 0x0f)
    185   {
    186     case BS_RADIOBUTTON:
    187     case BS_AUTORADIOBUTTON:
    188     case BS_OWNERDRAW:
    189       SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_DOUBLECLICKED),hwnd);
    190       break;
    191 
    192     default:
    193       BUTTON_LButtonDown(hwnd,wParam,lParam);
    194       break;
    195   }
     184  DWORD style = dwStyle & 0x0f;
     185
     186  if(dwStyle & BS_NOTIFY || style == BS_RADIOBUTTON ||
     187     style == BS_USERBUTTON || style == BS_OWNERDRAW)
     188    SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_DOUBLECLICKED),hwnd);
     189  else BUTTON_LButtonDown(hwnd,wParam,lParam);
    196190
    197191  return 0;
     
    200194static LRESULT BUTTON_LButtonDown(HWND hwnd,WPARAM wParam,LPARAM lParam)
    201195{
     196  SetCapture(hwnd);
     197  SetFocus(hwnd);
    202198  SendMessageA(hwnd,BM_SETSTATE,TRUE,0);
    203   SetFocus(hwnd);
    204   SetCapture(hwnd);
    205199
    206200  return 0;
     
    355349  DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & 0x0f;
    356350
    357   infoPtr->state |= BUTTON_HASFOCUS;
    358   if (style == BS_AUTORADIOBUTTON)
    359   {
    360     SendMessageA(hwnd,BM_SETCHECK,1,0);
    361     SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_CLICKED),hwnd);
    362   } else if (style == BS_RADIOBUTTON)
    363   {
     351  if ((style == BS_AUTORADIOBUTTON || style == BS_RADIOBUTTON) &&
     352      (GetCapture() != hwnd) && !(SendMessageA(hwnd,BM_GETCHECK,0,0) & BST_CHECKED))
     353  {
     354    /* The notification is sent when the button (BS_AUTORADIOBUTTON)
     355       is unckecked and the focus was not given by a mouse click. */
     356    if (style == BS_AUTORADIOBUTTON) SendMessageA(hwnd,BM_SETCHECK,TRUE,0);
    364357    SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),BN_CLICKED),hwnd);
    365358  }
    366359
     360  infoPtr->state |= BUTTON_HASFOCUS;
    367361  PAINT_BUTTON(hwnd,style,ODA_FOCUS);
    368362
     
    424418  HANDLE oldHbitmap = infoPtr->hImage;
    425419
    426   if (dwStyle & BS_BITMAP) infoPtr->hImage = (HANDLE)lParam;
     420  if (dwStyle & BS_BITMAP || dwStyle & BS_ICON) infoPtr->hImage = (HANDLE)lParam;
    427421
    428422  return oldHbitmap;
     
    433427  BUTTONINFO* infoPtr = (BUTTONINFO*)GetInfoPtr(hwnd);
    434428
    435   return infoPtr->hImage;
     429  switch(wParam)
     430  {
     431    case IMAGE_BITMAP:
     432      return (HBITMAP)infoPtr->hImage;
     433    case IMAGE_ICON:
     434      return (HICON)infoPtr->hImage;
     435    default:
     436      return NULL;
     437  }
    436438}
    437439
     
    600602 *       Push Button Functions
    601603 */
    602 
    603 static void PB_Paint(HWND hwnd,HDC hDC,WORD action)
    604 {
    605     BUTTONINFO* infoPtr = (BUTTONINFO*)GetInfoPtr(hwnd);
    606     DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    607     RECT rc;
     604static void PB_Paint( HWND hwnd, HDC hDC, WORD action )
     605{
     606    BUTTONINFO *infoPtr      = (BUTTONINFO *)GetInfoPtr(hwnd);
     607    BOOL        bHighLighted = (infoPtr->state & BUTTON_HIGHLIGHTED);
     608
     609    /*
     610     * Delegate this to the more generic pushbutton painting
     611     * method.
     612     */
     613    BUTTON_DrawPushButton(hwnd,
     614                          hDC,
     615                          action,
     616                          bHighLighted);
     617}
     618
     619/**********************************************************************
     620 * This method will actually do the drawing of the pushbutton
     621 * depending on it's state and the pushedState parameter.
     622 */
     623static void BUTTON_DrawPushButton(
     624  HWND hwnd,
     625  HDC  hDC,
     626  WORD action,
     627  BOOL pushedState )
     628{
     629    RECT rc, focus_rect;
    608630    HPEN hOldPen;
    609631    HBRUSH hOldBrush;
     632    BUTTONINFO *infoPtr = (BUTTONINFO *)GetInfoPtr(hwnd);
     633    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    610634    int xBorderOffset, yBorderOffset;
    611635    xBorderOffset = yBorderOffset = 0;
     
    613637    char* text;
    614638
    615     GetClientRect(hwnd,&rc );
     639    GetClientRect( hwnd, &rc );
    616640
    617641      /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
    618642    if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont );
    619     SendMessageA(GetParent(hwnd),WM_CTLCOLORBTN,hDC,hwnd);
    620 
     643    BUTTON_SEND_CTLCOLOR( hwnd, hDC );
    621644    hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME));
    622645    hOldBrush =(HBRUSH)SelectObject(hDC,GetSysColorBrush(COLOR_BTNFACE));
    623646    SetBkMode(hDC, TRANSPARENT);
    624     Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
    625 /*    if (action == ODA_DRAWENTIRE)*/
    626     {
    627         SetPixel( hDC, rc.left, rc.top, GetSysColor(COLOR_WINDOW) );
    628         SetPixel( hDC, rc.left, rc.bottom-1, GetSysColor(COLOR_WINDOW) );
    629         SetPixel( hDC, rc.right-1, rc.top, GetSysColor(COLOR_WINDOW) );
    630         SetPixel( hDC, rc.right-1, rc.bottom-1, GetSysColor(COLOR_WINDOW));
    631     }
    632     InflateRect( &rc, -1, -1 );
    633647
    634648    if ((dwStyle & 0x000f) == BS_DEFPUSHBUTTON)
    635649    {
    636650        Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
    637         InflateRect( &rc, -1, -1 );
    638     }
    639 
    640     if (infoPtr->state & BUTTON_HIGHLIGHTED)
    641     {
    642         /* draw button shadow: */
    643         SelectObject(hDC, GetSysColorBrush(COLOR_BTNSHADOW));
    644         PatBlt(hDC, rc.left, rc.top, 1, rc.bottom-rc.top, PATCOPY );
    645         PatBlt(hDC, rc.left, rc.top, rc.right-rc.left, 1, PATCOPY );
    646         rc.left += 2;  /* To position the text down and right */
    647         rc.top  += 2;
    648     } else {
    649         rc.right++, rc.bottom++;
    650         DrawEdge( hDC, &rc, EDGE_RAISED, BF_RECT );
    651 
    652         /* To place de bitmap correctly */
    653         xBorderOffset += GetSystemMetrics(SM_CXEDGE);
    654         yBorderOffset += GetSystemMetrics(SM_CYEDGE);
    655 
    656         rc.right--, rc.bottom--;
    657     }
    658 
    659     /* draw button label, if any: */
     651        InflateRect( &rc, -1, -1 );
     652    }
     653
     654    UINT uState = DFCS_BUTTONPUSH;
     655
     656    if (pushedState)
     657    {
     658      if ( (dwStyle & 0x000f) == BS_DEFPUSHBUTTON )
     659        uState |= DFCS_FLAT;
     660      else
     661        uState |= DFCS_PUSHED;
     662    }
     663
     664    DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
     665    InflateRect( &rc, -2, -2 );
     666
     667    focus_rect = rc;
     668
     669    if (pushedState)
     670    {
     671      rc.left += 2;  /* To position the text down and right */
     672      rc.top  += 2;
     673    }
     674
     675
     676    /* draw button label, if any:
     677     *
     678     * In win9x we don't show text if there is a bitmap or icon.
     679     * I don't know about win31 so I leave it as it was for win31.
     680     * Dennis Björklund 12 Jul, 99
     681     */
    660682    textLen = GetWindowTextLengthA(hwnd);
    661     if (textLen > 0)
     683    if (textLen > 0 && (!(dwStyle & (BS_ICON|BS_BITMAP))))
    662684    {
    663685        LOGBRUSH lb;
     
    668690        GetObjectA( GetSysColorBrush(COLOR_BTNFACE), sizeof(lb), &lb );
    669691        if (dwStyle & WS_DISABLED &&
    670             GetSysColor(COLOR_GRAYTEXT) == lb.lbColor)
     692            GetSysColor(COLOR_GRAYTEXT)==lb.lbColor)
    671693            /* don't write gray text on gray background */
    672694            PaintGrayOnGray( hDC,infoPtr->hFont,&rc,text,
    673                                DT_CENTER | DT_VCENTER );
     695                               DT_CENTER | DT_VCENTER );
    674696        else
    675697        {
     
    679701            DrawTextA( hDC, text, -1, &rc,
    680702                         DT_SINGLELINE | DT_CENTER | DT_VCENTER );
    681             /* do we have the focus? */
    682             if (infoPtr->state & BUTTON_HASFOCUS)
    683             {
    684                 RECT r = { 0, 0, 0, 0 };
    685                 INT xdelta, ydelta;
    686 
    687                 DrawTextA( hDC, text, -1, &r,
    688                              DT_SINGLELINE | DT_CALCRECT );
    689                 xdelta = ((rc.right - rc.left) - (r.right - r.left) - 1) / 2;
    690                 ydelta = ((rc.bottom - rc.top) - (r.bottom - r.top) - 1) / 2;
    691                 if (xdelta < 0) xdelta = 0;
    692                 if (ydelta < 0) ydelta = 0;
    693                 InflateRect( &rc, -xdelta, -ydelta );
    694                 DrawFocusRect( hDC, &rc );
    695             }
     703            /* do we have the focus?
     704             * Win9x draws focus last with a size prop. to the button
     705             */
    696706        }
    697707        free(text);
    698708    }
    699 
    700     if((dwStyle & BS_BITMAP) && (infoPtr->hImage != NULL))
    701     {
    702         BITMAP bm;
    703         HDC hdcMem;
    704         int yOffset, xOffset, imageWidth, imageHeight;
    705 
    706         GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm);
    707 
    708         /* Center the bitmap */
    709         xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - bm.bmWidth ) / 2;
    710         yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - bm.bmHeight ) / 2;
    711 
    712         imageWidth = bm.bmWidth;
    713         imageHeight = bm.bmHeight;
    714 
    715         /* If the image is to big for the button */
    716         if (xOffset < 0)
     709    if ( ((dwStyle & BS_ICON) || (dwStyle & BS_BITMAP) ) &&
     710         (infoPtr->hImage != NULL) )
     711    {
     712        int yOffset, xOffset;
     713        int imageWidth, imageHeight;
     714
     715        /*
     716         * We extract the size of the image from the handle.
     717         */
     718        if (dwStyle & BS_ICON)
     719        {
     720            ICONINFO iconInfo;
     721            BITMAP   bm;
     722
     723            GetIconInfo((HICON)infoPtr->hImage, &iconInfo);
     724            GetObjectA (iconInfo.hbmColor, sizeof(BITMAP), &bm);
     725       
     726            imageWidth  = bm.bmWidth;
     727            imageHeight = bm.bmHeight;
     728
     729            DeleteObject(iconInfo.hbmColor);
     730            DeleteObject(iconInfo.hbmMask);
     731
     732        }
     733        else
     734        {
     735            BITMAP   bm;
     736
     737            GetObjectA (infoPtr->hImage, sizeof(BITMAP), &bm);
     738       
     739            imageWidth  = bm.bmWidth;
     740            imageHeight = bm.bmHeight;
     741        }
     742
     743        /* Center the bitmap */
     744        xOffset = (((rc.right - rc.left) - 2*xBorderOffset) - imageWidth ) / 2;
     745        yOffset = (((rc.bottom - rc.top) - 2*yBorderOffset) - imageHeight) / 2;
     746
     747        /* If the image is too big for the button then create a region*/
     748        if(xOffset < 0 || yOffset < 0)
     749        {
     750            HRGN hBitmapRgn = NULL;
     751            hBitmapRgn = CreateRectRgn(
     752                rc.left + xBorderOffset, rc.top +yBorderOffset,
     753                rc.right - xBorderOffset, rc.bottom - yBorderOffset);
     754            SelectClipRgn(hDC, hBitmapRgn);
     755            DeleteObject(hBitmapRgn);
     756        }
     757
     758        /* Let minimum 1 space from border */
     759        xOffset++, yOffset++;
     760
     761        /*
     762         * Draw the image now.
     763         */
     764        if (dwStyle & BS_ICON)
     765        {
     766            DrawIcon(hDC,
     767                rc.left + xOffset, rc.top + yOffset,
     768                     (HICON)infoPtr->hImage);
     769        }
     770        else
    717771        {
    718             imageWidth = rc.right - rc.left - 2*xBorderOffset -1;
    719             xOffset = xBorderOffset;
     772            HDC hdcMem;
     773
     774            hdcMem = CreateCompatibleDC (hDC);
     775            SelectObject (hdcMem, (HBITMAP)infoPtr->hImage);
     776            BitBlt(hDC,
     777                   rc.left + xOffset,
     778                   rc.top + yOffset,
     779                   imageWidth, imageHeight,
     780                   hdcMem, 0, 0, SRCCOPY);
     781       
     782            DeleteDC (hdcMem);
     783        }
     784
     785        if(xOffset < 0 || yOffset < 0)
     786        {
     787            SelectClipRgn(hDC, NULL);
    720788        }
    721 
    722         if (yOffset < 0)
    723         {
    724             imageHeight = rc.bottom - rc.top - 2*yBorderOffset -1;
    725             yOffset = yBorderOffset;
    726         }
    727 
    728         /* Let minimum 1 space from border */
    729         xOffset++, yOffset++;
    730 
    731         hdcMem = CreateCompatibleDC (hDC);
    732         SelectObject (hdcMem, (HBITMAP)infoPtr->hImage);
    733         BitBlt(hDC, rc.left + xOffset,
    734                rc.top + yOffset,
    735                imageWidth, imageHeight,
    736                hdcMem, 0, 0, SRCCOPY);
    737 
    738         DeleteDC (hdcMem);
    739     }
     789    }
     790
     791    if (infoPtr->state & BUTTON_HASFOCUS)
     792    {
     793        InflateRect( &focus_rect, -1, -1 );
     794        DrawFocusRect( hDC, &focus_rect );
     795    }
     796
    740797
    741798    SelectObject( hDC, hOldPen );
    742799    SelectObject( hDC, hOldBrush );
    743800}
    744 
    745801
    746802/**********************************************************************
     
    812868    char* text = NULL;
    813869
     870    /*
     871     * if the button has a bitmap/icon, draw a normal pushbutton
     872     * instead of a radion button.
     873     */
     874    if (infoPtr->hImage!=NULL)
     875    {
     876        BOOL bHighLighted = ((infoPtr->state & BUTTON_HIGHLIGHTED) ||
     877                             (infoPtr->state & BUTTON_CHECKED));
     878
     879        BUTTON_DrawPushButton(hwnd,
     880                              hDC,
     881                              action,
     882                              bHighLighted);
     883        return;
     884    }
     885
    814886    textLen = 0;
    815887    GetClientRect(hwnd, &client);
     
    10191091    dis.itemData   = 0;
    10201092    GetClientRect( hwnd, &dis.rcItem );
     1093
     1094    SetBkColor( hDC, GetSysColor( COLOR_BTNFACE ) );
     1095    FillRect( hDC,  &dis.rcItem, GetSysColorBrush( COLOR_BTNFACE ) );
     1096
    10211097    SendMessageA( GetParent(hwnd), WM_DRAWITEM,
    10221098                    GetWindowLongA(hwnd,GWL_ID), (LPARAM)&dis );
  • trunk/src/user32/new/combo.cpp

    r387 r500  
    1 /* $Id: combo.cpp,v 1.2 1999-07-24 17:10:24 cbratschi Exp $ */
     1/* $Id: combo.cpp,v 1.3 1999-08-15 19:11:00 cbratschi Exp $ */
    22/*
    33 * Combo controls
     
    3939 * Look and feel dependant "constants"
    4040 */
     41#define COMBO_YBORDERGAP         5
    4142#define COMBO_XBORDERSIZE()      ( 2 )
    4243#define COMBO_YBORDERSIZE()      ( 2 )
     
    484485  if( lphc->owner || !(lpcs->style & WS_VISIBLE) )
    485486  {
    486       UINT      lbeStyle;
     487      UINT lbeStyle   = 0;
     488      UINT lbeExStyle = 0;
    487489
    488490      /*
     
    530532        lbeStyle |= LBS_DISABLENOSCROLL;
    531533
    532       if( CB_GETTYPE(lphc) == CBS_SIMPLE )      /* child listbox */
    533         lbeStyle |= WS_CHILD | WS_VISIBLE;
    534       else                                      /* popup listbox */
    535         lbeStyle |= WS_POPUP;
     534      if( CB_GETTYPE(lphc) == CBS_SIMPLE )      /* child listbox */
     535      {
     536        lbeStyle |= WS_CHILD | WS_VISIBLE;
     537
     538        /*
     539         * In win 95 look n feel, the listbox in the simple combobox has
     540         * the WS_EXCLIENTEDGE style instead of the WS_BORDER style.
     541         */
     542        lbeStyle   &= ~WS_BORDER;
     543        lbeExStyle |= WS_EX_CLIENTEDGE;
     544      }
     545      else                                      /* popup listbox */
     546        lbeStyle |= WS_POPUP;
    536547
    537548     /* Dropdown ComboLBox is not a child window and we cannot pass
    538549      * ID_CB_LISTBOX directly because it will be treated as a menu handle.
    539550      */
    540       lphc->hWndLBox = CreateWindowExA(0,
     551      lphc->hWndLBox = CreateWindowExA(lbeExStyle,
    541552                                       clbName,
    542553                                       NULL,
     
    10631074{
    10641075   RECT rect;
     1076   int nItems = 0;
     1077   int i;
     1078   int nHeight;
     1079   int nDroppedHeight;
    10651080
    10661081   //TRACE("[%04x]: drop down\n", CB_HWND(lphc));
     
    10911106   /* now set popup position */
    10921107   GetWindowRect( lphc->hwndself, &rect );
    1093 
    10941108
    10951109   /*
     
    10991113     rect.left += COMBO_EDITBUTTONSPACE();
    11001114
     1115   /* if the dropped height is greater than the total height of the dropped
     1116     items list, then force the drop down list height to be the total height
     1117     of the items in the dropped list */
     1118
     1119   nDroppedHeight = lphc->droppedRect.bottom - lphc->droppedRect.top;
     1120   nItems = (int)SendMessageA (lphc->hWndLBox, LB_GETCOUNT, 0, 0);
     1121   nHeight = COMBO_YBORDERGAP;
     1122   for (i = 0; i < nItems; i++)
     1123   {
     1124     nHeight += (int)SendMessageA (lphc->hWndLBox, LB_GETITEMHEIGHT, i, 0);
     1125
     1126     if (nHeight >= nDroppedHeight)
     1127       break;
     1128   }
     1129
     1130   if (nHeight < nDroppedHeight)
     1131      nDroppedHeight = nHeight;
     1132
    11011133   SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
    1102                  lphc->droppedRect.right - lphc->droppedRect.left,
    1103                  lphc->droppedRect.bottom - lphc->droppedRect.top,
    1104                  SWP_NOACTIVATE | SWP_NOREDRAW);
     1134                 lphc->droppedRect.right - lphc->droppedRect.left,
     1135                 nDroppedHeight,
     1136                 SWP_NOACTIVATE | SWP_NOREDRAW);
     1137
    11051138
    11061139   if( !(lphc->wState & CBF_NOREDRAW) )
     
    11271160       //TRACE("[%04x]: roll up [%i]\n", CB_HWND(lphc), (INT)ok );
    11281161
    1129        /*
    1130         * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling
    1131         * and with (0,0) (anywhere in the listbox) when Oking.
    1132         */
    1133        SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) );
    1134 
    11351162       if( lphc->wState & CBF_DROPPED )
    11361163       {
    11371164           RECT rect;
     1165
     1166           /*
     1167            * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling
     1168            * and with (0,0) (anywhere in the listbox) when Oking.
     1169            */
     1170           SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) );
    11381171
    11391172           lphc->wState &= ~CBF_DROPPED;
  • trunk/src/user32/new/edit.cpp

    r394 r500  
    1 /* $Id: edit.cpp,v 1.2 1999-07-25 16:31:44 cbratschi Exp $ */
     1/* $Id: edit.cpp,v 1.3 1999-08-15 19:11:00 cbratschi Exp $ */
    22/*
    33 *      Edit control
     
    1717 */
    1818
    19 //#include "config.h"
    2019#include "winuser.h"
    2120#include "winbase.h"
    2221#include <string.h>
    23 //#include "winnt.h"
    24 //#include "win.h"
    25 //#include "wine/winbase16.h"
    2622#include "controls.h"
    2723#include "combo.h"
    28 //#include "local.h"
    29 //#include "resource.h"
    30 //#include "debugtools.h"
    31 //#include "callback.h"
    32 //#include "tweak.h"
    3324
    3425#define BUFLIMIT_MULTI          65534   /* maximum buffer size (not including '\0')
     
    9889        INT line_count;         /* number of lines */
    9990        INT y_offset;                   /* scroll offset in number of lines */
     91        BOOL bCaptureState; /* flag indicating whether mouse was captured */
    10092        /*
    10193         *      only for multi line controls
     
    31563148                return 0;
    31573149
     3150        es->bCaptureState = TRUE;
    31583151        SetCapture(hwnd);
    31593152        EDIT_ConfinePoint(hwnd, es, &x, &y);
     
    31743167static LRESULT EDIT_WM_LButtonUp(HWND hwnd, EDITSTATE *es, DWORD keys, INT x, INT y)
    31753168{
    3176         if (GetCapture() == hwnd) {
    3177                 KillTimer(hwnd, 0);
    3178                 ReleaseCapture();
    3179         }
    3180         return 0;
     3169        if (es->bCaptureState && GetCapture() == hwnd) {
     3170                KillTimer(hwnd, 0);
     3171                ReleaseCapture();
     3172        }
     3173        es->bCaptureState = FALSE;
     3174
     3175        return 0;
    31813176}
    31823177
     
    32333228        es->style = cs->style;
    32343229
    3235         if ((es->style & WS_BORDER) && !(es->style & WS_DLGFRAME))
    3236                 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~WS_BORDER);
    3237 
     3230
     3231        /*
     3232         * In Win95 look and feel, the WS_BORDER style is replaced by the
     3233         * WS_EX_CLIENTEDGE style for the edit control. This gives the edit
     3234         * control a non client area.
     3235         */
     3236        if (es->style & WS_BORDER)
     3237        {
     3238          es->style      &= ~WS_BORDER;
     3239          SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~WS_BORDER);
     3240          SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
     3241        }
     3242       
    32383243        if (es->style & ES_MULTILINE) {
    32393244                es->buffer_size = BUFSTART_MULTI;
     
    33163321                        if(es->style & WS_VSCROLL) rc.right++;
    33173322                }
    3318                 DrawEdge(dc, &rc, EDGE_SUNKEN, BF_RECT);
     3323                Rectangle(dc, rc.left, rc.top, rc.right, rc.bottom);
    33193324        }
    33203325        IntersectClipRect(dc, es->format_rect.left,
  • trunk/src/user32/new/listbox.cpp

    r387 r500  
    1 /* $Id: listbox.cpp,v 1.2 1999-07-24 17:10:25 cbratschi Exp $ */
     1/* $Id: listbox.cpp,v 1.3 1999-08-15 19:11:01 cbratschi Exp $ */
    22/*
    33 * Listbox controls
     
    9090    (!IS_OWNERDRAW(descr) || ((descr)->style & LBS_HASSTRINGS))
    9191
     92#define IS_MULTISELECT(descr) \
     93    ((descr)->style & LBS_MULTIPLESEL || ((descr)->style & LBS_EXTENDEDSEL))
     94
    9295#define SEND_NOTIFICATION(hwnd,descr,code) \
    9396    (SendMessageA( (descr)->owner, WM_COMMAND, \
     
    12261229        if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT);
    12271230        if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT );
    1228         if (send_notify) SEND_NOTIFICATION( hwnd, descr,
     1231        if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr,
    12291232                               (index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL );
    12301233        else
     
    12731276    LB_ITEMDATA *item;
    12741277    INT max_items;
     1278    INT oldfocus = descr->focus_item;
    12751279
    12761280    if (index == -1) index = descr->nb_items;
     
    13271331
    13281332    /* Move selection and focused item */
    1329 
    1330     if (index <= descr->selected_item) descr->selected_item++;
    1331     if (index <= descr->focus_item)
    1332     {
    1333         descr->focus_item++;
    1334         LISTBOX_MoveCaret( hwnd, descr, descr->focus_item, FALSE );
    1335     }
    1336 
    13371333    /* If listbox was empty, set focus to the first item */
    1338 
    1339     if (descr->nb_items == 1) LISTBOX_SetCaretIndex( hwnd, descr, 0, FALSE );
     1334    if (descr->nb_items == 1)
     1335         LISTBOX_SetCaretIndex( hwnd, descr, 0, FALSE );
     1336    /* single select don't change selection index in win31 */
     1337    else
     1338    {
     1339        if (index <= descr->selected_item)
     1340        {
     1341           descr->selected_item++;
     1342           descr->focus_item = oldfocus; /* focus not changed */
     1343        }
     1344    }
    13401345    return LB_OKAY;
    13411346}
     
    13641369    if (HAS_STRINGS(descr))
    13651370    {
     1371        if (!str) str="";
    13661372        if (!(new_str = HEAP_strdupA( descr->heap, 0, str )))
    13671373        {
     
    14511457
    14521458    LISTBOX_UpdateScroll( hwnd, descr );
     1459    /* if we removed the scrollbar, reset the top of the list
     1460      (correct for owner-drawn ???) */
     1461    if (descr->nb_items == descr->page_size)
     1462        LISTBOX_SetTopItem( hwnd, descr, 0, TRUE );
     1463
     1464    /* Move selection and focused item */
     1465    if (!IS_MULTISELECT(descr))
     1466    {
     1467        if (index == descr->selected_item)
     1468            descr->selected_item = -1;
     1469        else if (index < descr->selected_item)
     1470      {
     1471            descr->selected_item--;
     1472      }
     1473    }
    14531474    LISTBOX_InvalidateItems( hwnd, descr, index );
    1454 
    1455     /* Move selection and focused item */
    1456 
    1457     if (index <= descr->selected_item) descr->selected_item--;
    1458     if (index <= descr->focus_item)
    1459     {
    1460         descr->focus_item--;
    1461         LISTBOX_MoveCaret( hwnd, descr, descr->focus_item, FALSE );
     1475    if (descr->focus_item >= descr->nb_items)
     1476    {
     1477          descr->focus_item = descr->nb_items - 1;
     1478          if (descr->focus_item < 0) descr->focus_item = 0;
    14621479    }
    14631480    return LB_OKAY;
     
    17811798        descr->captured = FALSE;
    17821799        if (GetCapture() == hwnd) ReleaseCapture();
    1783         if (descr->style & LBS_NOTIFY)
     1800        if ((descr->style & LBS_NOTIFY) && descr->nb_items)
    17841801            SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE );
    17851802    }
     
    19041921{
    19051922    INT caret = -1;
     1923    BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */
     1924
     1925    if ((IS_MULTISELECT(descr)) || (descr->selected_item == descr->focus_item))
     1926       bForceSelection = FALSE; /* only for single select list */
     1927
    19061928    if (descr->style & LBS_WANTKEYBOARDINPUT)
    19071929    {
     
    19161938        if (descr->style & LBS_MULTICOLUMN)
    19171939        {
     1940            bForceSelection = FALSE;
    19181941            if (descr->focus_item >= descr->page_size)
    19191942                caret = descr->focus_item - descr->page_size;
     
    19281951        if (descr->style & LBS_MULTICOLUMN)
    19291952        {
     1953            bForceSelection = FALSE;
    19301954            if (descr->focus_item + descr->page_size < descr->nb_items)
    19311955                caret = descr->focus_item + descr->page_size;
     
    19711995                                  (descr->style & LBS_NOTIFY) != 0 );
    19721996        }
    1973         else if (descr->selected_item == -1)
    1974         {
    1975             LISTBOX_SetSelection( hwnd, descr, descr->focus_item, TRUE,
    1976                                   (descr->style & LBS_NOTIFY) != 0 );
    1977         }
    19781997        break;
    1979     }
     1998    default:
     1999        bForceSelection = FALSE;
     2000    }
     2001    if (bForceSelection) /* focused item is used instead of key */
     2002        caret = descr->focus_item;
    19802003    if (caret >= 0)
    19812004    {
     
    19842007            descr->anchor_item = caret;
    19852008        LISTBOX_MoveCaret( hwnd, descr, caret, TRUE );
     2009        LISTBOX_SetSelection( hwnd, descr, caret, TRUE, FALSE);
    19862010        if (descr->style & LBS_NOTIFY)
    19872011        {
     
    19912015                descr->lphc->wState |= CBF_NOROLLUP;
    19922016            }
    1993             SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE );
     2017            if (descr->nb_items) SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE );
    19942018        }
    19952019    }
     
    20212045    if (caret != -1)
    20222046    {
     2047        if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1)
     2048           LISTBOX_SetSelection( hwnd, descr, caret, TRUE, FALSE);
    20232049        LISTBOX_MoveCaret( hwnd, descr, caret, TRUE );
    2024         if (descr->style & LBS_NOTIFY)
     2050        if ((descr->style & LBS_NOTIFY) && descr->nb_items)
    20252051            SEND_NOTIFICATION( hwnd, descr, LBN_SELCHANGE );
    20262052    }
     
    21352161    if (!(descr = (LB_DESCR*)GetInfoPtr(hwnd)))
    21362162    {
    2137         if (msg == WM_CREATE)
    2138         {
    2139             if (!LISTBOX_Create( hwnd, NULL ))
    2140                 return -1;
    2141             //TRACE("creating wnd=%04x descr=%p\n",
    2142             //             hwnd, *(LB_DESCR **)wnd->wExtra );
    2143             return 0;
    2144         }
     2163        switch (msg)
     2164        {
     2165            case WM_CREATE:
     2166            {
     2167                if (!LISTBOX_Create( hwnd, NULL ))
     2168                     return -1;
     2169                //TRACE("creating wnd=%04x descr=%p\n",
     2170                //      hwnd, *(LB_DESCR **)wnd->wExtra );
     2171                return 0;
     2172            }
     2173            case WM_NCCREATE:
     2174            {
     2175                DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     2176       
     2177                /*
     2178                 * When a listbox is not in a combobox and the look
     2179                 * is win95,  the WS_BORDER style is replaced with
     2180                 * the WS_EX_CLIENTEDGE style.
     2181                 */
     2182                if (dwStyle & WS_BORDER)
     2183                {
     2184                    SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
     2185                    SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE)  & ~ WS_BORDER);
     2186                }
     2187            }
     2188        }
    21452189        /* Ignore all other messages before we get a WM_CREATE */
    21462190        return DefWindowProcA( hwnd, msg, wParam, lParam );
     
    21672211
    21682212    case LB_DELETESTRING:
    2169         return LISTBOX_RemoveItem( hwnd, descr, wParam );
     2213        if (LISTBOX_RemoveItem( hwnd, descr, wParam) != LB_ERR)
     2214           return descr->nb_items;
     2215        else
     2216           return LB_ERR;       
    21702217
    21712218    case LB_GETITEMDATA:
     
    21952242        if (descr->nb_items==0)
    21962243          return LB_ERR;
     2244        if (!IS_MULTISELECT(descr))
     2245          return descr->selected_item;
    21972246        /* else */
    21982247        if (descr->selected_item!=-1)
     
    22282277
    22292278    case LB_SETCARETINDEX:
    2230         return LISTBOX_SetCaretIndex( hwnd, descr, wParam, !lParam );
     2279        if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR;
     2280        if (LISTBOX_SetCaretIndex( hwnd, descr, wParam, !lParam ) == LB_ERR)
     2281            return LB_ERR;
     2282        else
     2283             return LB_OKAY;
    22312284
    22322285    case LB_GETCARETINDEX:
     
    22672320
    22682321    case LB_SETCURSEL:
     2322        if (IS_MULTISELECT(descr)) return LB_ERR;
    22692323        LISTBOX_SetCaretIndex( hwnd, descr, wParam, TRUE );
    22702324        return LISTBOX_SetSelection( hwnd, descr, wParam, TRUE, FALSE );
     
    24362490        break;
    24372491
    2438     case WM_NCCREATE:
    2439         SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
    2440         return DefWindowProcA( hwnd, msg, wParam, lParam );
    24412492    default:
    24422493        //if ((msg >= WM_USER) && (msg < 0xc000))
  • trunk/src/user32/new/scroll.cpp

    r387 r500  
    1 /* $Id: scroll.cpp,v 1.4 1999-07-24 17:10:25 cbratschi Exp $ */
     1/* $Id: scroll.cpp,v 1.5 1999-08-15 19:11:01 cbratschi Exp $ */
    22/*
    33 * Scrollbar control
     
    5252
    5353  /* Overlap between arrows and thumb */
    54 #define SCROLL_ARROW_THUMB_OVERLAP 1
     54#define SCROLL_ARROW_THUMB_OVERLAP 0
    5555
    5656  /* Delay (in ms) before first repetition when holding the button down */
     
    9797static INT SCROLL_SetScrollInfo( HWND hwnd, INT nBar,
    9898                                   const SCROLLINFO *info, INT *action );
     99static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar,
     100                                    RECT *rect, INT arrowSize,
     101                                    INT thumbSize, INT thumbPos,
     102                                    UINT flags, BOOL vertical,
     103                                    BOOL top_selected, BOOL bottom_selected );
    99104
    100105/***********************************************************************
     
    379384}
    380385
    381 
    382386/***********************************************************************
    383387 *           SCROLL_DrawArrows
     
    385389 * Draw the scroll bar arrows.
    386390 */
     391static void SCROLL_DrawArrows_9x( HDC hdc, SCROLLBAR_INFO *infoPtr,
     392                                  RECT *rect, INT arrowSize, BOOL vertical,
     393                                  BOOL top_pressed, BOOL bottom_pressed )
     394{
     395  RECT r;
     396
     397  r = *rect;
     398  if( vertical )
     399    r.bottom = r.top + arrowSize;
     400  else
     401    r.right = r.left + arrowSize;
     402
     403  DrawFrameControl( hdc, &r, DFC_SCROLL,
     404                    (vertical ? DFCS_SCROLLUP : DFCS_SCROLLLEFT)
     405                    | (top_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
     406                    | (infoPtr->flags&ESB_DISABLE_LTUP ? DFCS_INACTIVE : 0 ) );
     407
     408  r = *rect;
     409  if( vertical )
     410    r.top = r.bottom-arrowSize;
     411  else
     412    r.left = r.right-arrowSize;
     413
     414  DrawFrameControl( hdc, &r, DFC_SCROLL,
     415                    (vertical ? DFCS_SCROLLDOWN : DFCS_SCROLLRIGHT)
     416                    | (bottom_pressed ? (DFCS_PUSHED | DFCS_FLAT) : 0 )
     417                    | (infoPtr->flags&ESB_DISABLE_RTDN ? DFCS_INACTIVE : 0) );
     418}
     419
    387420static void SCROLL_DrawArrows( HDC hdc, SCROLLBAR_INFO *infoPtr,
    388                                RECT *rect, INT arrowSize, BOOL vertical,
    389                                BOOL top_pressed, BOOL bottom_pressed )
    390 {
    391     HDC hdcMem = CreateCompatibleDC( hdc );
    392     HBITMAP hbmpPrev = SelectObject( hdcMem, vertical ?
    393                                     TOP_ARROW(infoPtr->flags, top_pressed)
    394                                     : LEFT_ARROW(infoPtr->flags, top_pressed));
    395     INT offset = 1;
    396 
    397     if (offset) arrowSize--;
    398     SetStretchBltMode( hdc, STRETCH_DELETESCANS );
    399     StretchBlt( hdc, rect->left+offset, rect->top+offset,
    400                   vertical ? rect->right-(rect->left+offset) : arrowSize,
    401                   vertical ? arrowSize : rect->bottom-(rect->top+offset),
    402                   hdcMem, 0, 0,
    403                   GetSystemMetrics(SM_CXVSCROLL),GetSystemMetrics(SM_CYHSCROLL),
    404                   SRCCOPY );
    405 
    406     SelectObject( hdcMem, vertical ?
    407                     BOTTOM_ARROW( infoPtr->flags, bottom_pressed )
    408                     : RIGHT_ARROW( infoPtr->flags, bottom_pressed ) );
    409     if (vertical)
    410         StretchBlt( hdc, (rect->left+offset), rect->bottom - arrowSize,
    411                       rect->right - (rect->left+offset), arrowSize,
    412                       hdcMem, 0, 0,
    413                       GetSystemMetrics(SM_CXVSCROLL),GetSystemMetrics(SM_CYHSCROLL),
    414                       SRCCOPY );
    415     else
    416         StretchBlt( hdc, rect->right - arrowSize, rect->top+offset,
    417                       arrowSize, rect->bottom - (rect->top+offset),
    418                       hdcMem, 0, 0,
    419                       GetSystemMetrics(SM_CXVSCROLL), GetSystemMetrics(SM_CYHSCROLL),
    420                       SRCCOPY );
    421     SelectObject( hdcMem, hbmpPrev );
    422     DeleteDC( hdcMem );
     421                               RECT *rect, INT arrowSize, BOOL vertical,
     422                               BOOL top_pressed, BOOL bottom_pressed )
     423{
     424  SCROLL_DrawArrows_9x( hdc, infoPtr, rect, arrowSize,
     425                        vertical, top_pressed,bottom_pressed );
    423426}
    424427
     
    429432 * Draw the moving thumb rectangle.
    430433 */
     434static void SCROLL_DrawMovingThumb_9x( HDC hdc, RECT *rect, BOOL vertical,
     435                                       INT arrowSize, INT thumbSize )
     436{
     437  INT pos = SCROLL_TrackingPos;
     438  INT max_size;
     439
     440  if( vertical )
     441    max_size = rect->bottom - rect->top;
     442  else
     443    max_size = rect->right - rect->left;
     444
     445  max_size -= (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) + thumbSize;
     446
     447  if( pos < (arrowSize-SCROLL_ARROW_THUMB_OVERLAP) )
     448    pos = (arrowSize-SCROLL_ARROW_THUMB_OVERLAP);
     449  else if( pos > max_size )
     450    pos = max_size;
     451
     452  SCROLL_DrawInterior_9x( SCROLL_TrackingWin, hdc, SCROLL_TrackingBar,
     453                          rect, arrowSize, thumbSize, pos,
     454                          0, vertical, FALSE, FALSE );
     455                       
     456  SCROLL_MovingThumb = !SCROLL_MovingThumb;
     457}
     458
    431459static void SCROLL_DrawMovingThumb( HDC hdc, RECT *rect, BOOL vertical,
    432                                     INT arrowSize, INT thumbSize )
    433 {
    434     RECT r = *rect;
    435     if (vertical)
    436     {
    437         r.top += SCROLL_TrackingPos;
    438         if (r.top < rect->top + arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
    439             r.top = rect->top + arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
    440         if (r.top + thumbSize >
    441                        rect->bottom - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP))
    442             r.top = rect->bottom - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
    443                                                                   - thumbSize;
    444         r.bottom = r.top + thumbSize;
    445     }
    446     else
    447     {
    448         r.left += SCROLL_TrackingPos;
    449         if (r.left < rect->left + arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
    450             r.left = rect->left + arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
    451         if (r.left + thumbSize >
    452                        rect->right - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP))
    453             r.left = rect->right - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP)
    454                                                                   - thumbSize;
    455         r.right = r.left + thumbSize;
    456     }
    457     DrawFocusRect( hdc, &r );
    458     SCROLL_MovingThumb = !SCROLL_MovingThumb;
    459 }
    460 
     460                                    INT arrowSize, INT thumbSize )
     461{
     462  SCROLL_DrawMovingThumb_9x( hdc, rect, vertical, arrowSize, thumbSize );
     463}
    461464
    462465/***********************************************************************
     
    465468 * Draw the scroll bar interior (everything except the arrows).
    466469 */
     470static void SCROLL_DrawInterior_9x( HWND hwnd, HDC hdc, INT nBar,
     471                                    RECT *rect, INT arrowSize,
     472                                    INT thumbSize, INT thumbPos,
     473                                    UINT flags, BOOL vertical,
     474                                    BOOL top_selected, BOOL bottom_selected )
     475{
     476    RECT r;
     477    HPEN hSavePen;
     478    HBRUSH hSaveBrush,hBrush;
     479
     480    /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
     481     * The window-owned scrollbars need to call DEFWND_ControlColor
     482     * to correctly setup default scrollbar colors
     483     */
     484    if (nBar == SB_CTL)
     485    {
     486      hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
     487                                     (WPARAM)hdc,(LPARAM)hwnd);
     488    }
     489    else
     490    {
     491      //CB: implement!
     492      //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
     493    }
     494
     495    hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
     496    hSaveBrush = SelectObject( hdc, hBrush );
     497
     498    /* Calculate the scroll rectangle */
     499    r = *rect;
     500    if (vertical)
     501    {
     502        r.top    += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
     503        r.bottom -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
     504    }
     505    else
     506    {
     507        r.left  += arrowSize - SCROLL_ARROW_THUMB_OVERLAP;
     508        r.right -= (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
     509    }
     510
     511    /* Draw the scroll rectangles and thumb */
     512    if (!thumbPos)  /* No thumb to draw */
     513    {
     514        PatBlt( hdc, r.left, r.top,
     515                     r.right - r.left, r.bottom - r.top,
     516                     PATCOPY );
     517
     518        /* cleanup and return */
     519        SelectObject( hdc, hSavePen );
     520        SelectObject( hdc, hSaveBrush );
     521        return;
     522    }
     523
     524    if (vertical)
     525    {
     526        PatBlt( hdc, r.left, r.top,
     527                  r.right - r.left,
     528                  thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
     529                  top_selected ? 0x0f0000 : PATCOPY );
     530        r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
     531        PatBlt( hdc, r.left, r.top + thumbSize,
     532                  r.right - r.left,
     533                  r.bottom - r.top - thumbSize,
     534                  bottom_selected ? 0x0f0000 : PATCOPY );
     535        r.bottom = r.top + thumbSize;
     536    }
     537    else  /* horizontal */
     538    {
     539        PatBlt( hdc, r.left, r.top,
     540                  thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
     541                  r.bottom - r.top,
     542                  top_selected ? 0x0f0000 : PATCOPY );
     543        r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
     544        PatBlt( hdc, r.left + thumbSize, r.top,
     545                  r.right - r.left - thumbSize,
     546                  r.bottom - r.top,
     547                  bottom_selected ? 0x0f0000 : PATCOPY );
     548        r.right = r.left + thumbSize;
     549    }
     550
     551    /* Draw the thumb */
     552    DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT | BF_MIDDLE  );
     553
     554    /* cleanup */
     555    SelectObject( hdc, hSavePen );
     556    SelectObject( hdc, hSaveBrush );
     557}
     558
     559
    467560static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar,
    468561                                 RECT *rect, INT arrowSize,
     
    483576      /* Select the correct brush and pen */
    484577
    485     if ((flags & ESB_DISABLE_BOTH) == ESB_DISABLE_BOTH)
    486     {
    487         /* This ought to be the color of the parent window */
    488         //hBrush = GetSysColorBrush(COLOR_WINDOW);
    489         /* Under Win9x look & feel, scrollbars don't have a solid border.
    490          * To make scrollbar's background different from the window
    491          * background, we need to apply a gray 0x55aa pattern brush.
    492          * Otherwise it won't look good.
    493          */
    494          //hBrush = CACHE_GetPattern55AABrush();
    495          hBrush = GetSysColorBrush(COLOR_3DFACE); //CB: improve!
    496     }
    497     else
    498     {
    499         /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
    500          * The window-owned scrollbars need to call DEFWND_ControlColor
    501          * to correctly setup default scrollbar colors
    502          */
    503         if (nBar == SB_CTL) {
    504             hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
    505                                            (WPARAM)hdc,(LPARAM)hwnd);
    506         } else {
    507 /* CB: implement later!
    508             hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
    509 */
    510         }
    511     }
     578    /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR.
     579     * The window-owned scrollbars need to call DEFWND_ControlColor
     580     * to correctly setup default scrollbar colors
     581     */
     582    if (nBar == SB_CTL) {
     583        hBrush = (HBRUSH)SendMessageA( GetParent(hwnd), WM_CTLCOLORSCROLLBAR,
     584                                       (WPARAM)hdc,(LPARAM)hwnd);
     585    } else {
     586        //CB: implement!
     587        //hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR );
     588    }
     589
    512590    hSavePen = SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
    513591    hSaveBrush = SelectObject( hdc, hBrush );
     
    527605    }
    528606
     607      /* Draw the scroll bar frame */
     608
     609        /* Only draw outline if Win 3.1.  Mar 24, 1999 - Ronald B. Cemer */
     610
    529611      /* Draw the scroll rectangles and thumb */
    530612
    531613    if (!thumbPos)  /* No thumb to draw */
    532614    {
    533         PatBlt( hdc, r.left+1, r.top+1, r.right - r.left - 2,
    534                   r.bottom - r.top - 2, PATCOPY );
     615        INT offset = 0;
     616
     617        PatBlt( hdc, r.left+offset, r.top+offset,
     618                     r.right - r.left - 2*offset, r.bottom - r.top - 2*offset,
     619                     PATCOPY );
    535620
    536621        /* cleanup and return */
     
    542627    if (vertical)
    543628    {
    544         PatBlt( hdc, r.left + 1, r.top + 1,
    545                   r.right - r.left - 2,
    546                   thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - 1,
     629        INT offset = 0;
     630
     631        PatBlt( hdc, r.left + offset, r.top + offset,
     632                  r.right - r.left - offset*2,
     633                  thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - offset,
    547634                  top_selected ? 0x0f0000 : PATCOPY );
    548635        r.top += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
    549         PatBlt( hdc, r.left + 1, r.top + thumbSize,
    550                   r.right - r.left - 2,
    551                   r.bottom - r.top - thumbSize - 1,
     636        PatBlt( hdc, r.left + offset, r.top + thumbSize,
     637                  r.right - r.left - offset*2,
     638                  r.bottom - r.top - thumbSize - offset,
    552639                  bottom_selected ? 0x0f0000 : PATCOPY );
    553640        r.bottom = r.top + thumbSize;
     
    555642    else  /* horizontal */
    556643    {
    557         PatBlt( hdc, r.left + 1, r.top + 1,
    558                   thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP) - 1,
    559                   r.bottom - r.top - 2,
     644        INT offset = 0;
     645
     646        PatBlt( hdc, r.left + offset, r.top + offset,
     647                  thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP),
     648                  r.bottom - r.top - offset*2,
    560649                  top_selected ? 0x0f0000 : PATCOPY );
    561650        r.left += thumbPos - (arrowSize - SCROLL_ARROW_THUMB_OVERLAP);
    562         PatBlt( hdc, r.left + thumbSize, r.top + 1,
    563                   r.right - r.left - thumbSize - 1,
    564                   r.bottom - r.top - 2,
     651        PatBlt( hdc, r.left + thumbSize, r.top + offset,
     652                  r.right - r.left - thumbSize - offset,
     653                  r.bottom - r.top - offset*2,
    565654                  bottom_selected ? 0x0f0000 : PATCOPY );
    566655        r.right = r.left + thumbSize;
     
    571660    SelectObject( hdc, GetSysColorBrush(COLOR_BTNFACE) );
    572661
    573     r.top++, r.left++;
    574     r.bottom--; r.right--;
    575     Rectangle( hdc, r.left, r.top, r.right-1, r.bottom-1 );
     662    Rectangle( hdc, r.left+1, r.top+1, r.right-1, r.bottom-1 );
    576663
    577664    DrawEdge( hdc, &r, EDGE_RAISED, BF_RECT );
     
    586673    SelectObject( hdc, hSaveBrush );
    587674}
    588 
    589675
    590676/***********************************************************************
     
    770856                SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
    771857                                SB_LINEUP, hwndCtl );
    772                 //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
    773                 //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
    774                 //                  (TIMERPROC)0 );
    775858            }
     859            //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
     860            //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
     861            //                  (TIMERPROC)0 );
    776862        }
    777863        //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
     
    871957                SendMessageA( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL,
    872958                                SB_LINEDOWN, hwndCtl );
    873                 //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
    874                 //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
    875                 //                  (TIMERPROC)0 );
    876959            }
     960            //CB: SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ?
     961            //                  SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY,
     962            //                  (TIMERPROC)0 );
    877963        }
    878964        //CB: else KillSystemTimer( hwnd, SCROLL_TIMER );
  • trunk/src/user32/new/static.cpp

    r387 r500  
    1 /* $Id: static.cpp,v 1.4 1999-07-24 17:10:26 cbratschi Exp $ */
     1/* $Id: static.cpp,v 1.5 1999-08-15 19:11:01 cbratschi Exp $ */
    22/*
    33 * Static control
     
    8383 * Set the bitmap for an SS_BITMAP control.
    8484 */
    85 static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hbitmap )
    86 {
    87     HBITMAP prevIcon;
     85static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap )
     86{
     87    HBITMAP hOldBitmap;
    8888    STATICINFO *infoPtr = (STATICINFO *)GetInfoPtr(hwnd);
    8989    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     
    9191    if ((dwStyle & SS_TYPEMASK) != SS_BITMAP) return 0;
    9292
    93     if (infoPtr->hIcon) DeleteObject(infoPtr->hIcon);
    94     prevIcon = infoPtr->hIcon;
    95     infoPtr->hIcon = hbitmap;
    96 
    97     if (hbitmap)
     93    if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) {
     94        //ERR("huh? hBitmap!=0, but not bitmap\n");
     95        return 0;
     96    }
     97    hOldBitmap = infoPtr->hIcon;
     98    infoPtr->hIcon = hBitmap;
     99    if (hBitmap)
    98100    {
     101        BITMAP bm;
     102        GetObjectA(hBitmap, sizeof(bm), &bm);
     103        SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
     104                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
     105/* CB: alternative code, if necessary
    99106      HDC hdc = GetDC(hwnd);
    100107      BITMAPINFO info;
     
    106113      }
    107114      ReleaseDC(hwnd,hdc);
    108     }
    109 
    110     return prevIcon;
    111 }
    112 
     115*/                     
     116               
     117    }
     118    return hOldBitmap;
     119}
    113120
    114121/***********************************************************************
     
    535542                             hdc, hwnd );
    536543    FillRect( hdc, &rc, hbrush );
    537     if (infoPtr->hIcon)
    538       DrawIcon(hdc,0,0,infoPtr->hIcon);
     544
     545    if (infoPtr->hIcon) {
     546        BITMAP bm;
     547        SIZE sz;
     548
     549        if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP)
     550            return;
     551        if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
     552        GetObjectA(infoPtr->hIcon, sizeof(bm), &bm);
     553        GetBitmapDimensionEx(infoPtr->hIcon, &sz);
     554        oldbitmap = SelectObject(hMemDC, infoPtr->hIcon);
     555        BitBlt(hdc, sz.cx, sz.cy, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
     556               SRCCOPY);
     557        SelectObject(hMemDC, oldbitmap);
     558        DeleteDC(hMemDC);
     559    }
    539560}
    540561
  • trunk/src/user32/new/uitools.cpp

    r407 r500  
    1 /* $Id: uitools.cpp,v 1.2 1999-08-03 21:22:34 sandervl Exp $ */
     1/* $Id: uitools.cpp,v 1.3 1999-08-15 19:11:02 cbratschi Exp $ */
    22/*
    33 * User Interface Functions
     
    462462        LTInnerI = RBInnerI = LTRBInnerFlat[uType & (BDR_INNER|BDR_OUTER)];
    463463        LTOuterI = RBOuterI = LTRBOuterFlat[uType & (BDR_INNER|BDR_OUTER)];
     464
     465        /* Bertho Stultiens states above that this function exactly matches win95
     466         * In win98 BF_FLAT rectangels have an inner border same color as the
     467         * middle (COLOR_BTNFACE). I believe it's the same for win95 but since
     468         * I don't know I go with Bertho and just sets it for win98 until proven
     469         * otherwise.
     470         *                                          Dennis Björklund, 10 June, 99
     471         */
     472        if(LTInnerI != -1 )     
     473            LTInnerI = RBInnerI = COLOR_BTNFACE;
    464474    }
    465475    else if(uFlags & BF_SOFT)
     
    488498    if(RBOuterI != -1) RBOuterPen = GetSysColorPen(RBOuterI);
    489499
    490     if((uFlags & BF_MIDDLE) && retval)
    491     {
    492         FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ?
    493                                             COLOR_WINDOW : COLOR_BTNFACE));
    494     }
    495 
    496500    MoveToEx(hdc, 0, 0, &SavePoint);
    497501
     
    545549    }
    546550
    547     /* Adjust rectangle if asked */
    548     if(uFlags & BF_ADJUST)
     551    if( ((uFlags & BF_MIDDLE) && retval) || (uFlags & BF_ADJUST) )
    549552    {
    550553        int add = (LTRBInnerMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0)
    551554                + (LTRBOuterMono[uType & (BDR_INNER|BDR_OUTER)] != -1 ? 1 : 0);
    552         if(uFlags & BF_LEFT)   rc->left   += add;
    553         if(uFlags & BF_RIGHT)  rc->right  -= add;
    554         if(uFlags & BF_TOP)    rc->top    += add;
    555         if(uFlags & BF_BOTTOM) rc->bottom -= add;
     555
     556        if(uFlags & BF_LEFT)   InnerRect.left   += add;
     557        if(uFlags & BF_RIGHT)  InnerRect.right  -= add;
     558        if(uFlags & BF_TOP)    InnerRect.top    += add;
     559        if(uFlags & BF_BOTTOM) InnerRect.bottom -= add;
     560
     561        if((uFlags & BF_MIDDLE) && retval)
     562        {
     563            FillRect(hdc, &InnerRect, GetSysColorBrush(uFlags & BF_MONO ?
     564                                                       COLOR_WINDOW : COLOR_BTNFACE));
     565        }
     566
     567        if(uFlags & BF_ADJUST)
     568            *rc = InnerRect;
    556569    }
    557570
     
    11241137    HBRUSH hbsave, hb, hb2;
    11251138    HPEN hpsave, hp, hp2;
    1126     int tri = 310*SmallDiam/1000;
     1139    int tri = 290*SmallDiam/1000 -1;
    11271140    int d46, d93;
    11281141
     
    11401153    case DFCS_SCROLLUP:
    11411154        Line[2].x = myr.left + 470*SmallDiam/1000 + 2;
    1142         Line[2].y = myr.top  + 313*SmallDiam/1000 + 1;
     1155        Line[2].y = myr.bottom - 687*SmallDiam/1000 + 1;
    11431156        Line[0].x = Line[2].x - tri;
    11441157        Line[1].x = Line[2].x + tri;
     
    11471160
    11481161    case DFCS_SCROLLLEFT:
    1149         Line[2].x = myr.left + 313*SmallDiam/1000 + 1;
     1162        Line[2].x = myr.right - 687*SmallDiam/1000 + 1;
    11501163        Line[2].y = myr.top  + 470*SmallDiam/1000 + 2;
    11511164        Line[0].y = Line[2].y - tri;
     
    12421255
    12431256    /* Here do the real scroll-bar controls end up */
    1244     UITOOLS95_DFC_ButtonPush(dc, r, uFlags & 0xff00);
     1257    if( ! (uFlags & (0xff00 & ~DFCS_ADJUSTRECT)) )
     1258      /* UITOOLS95_DFC_ButtonPush always uses BF_SOFT which we don't */
     1259      /* want for the normal scroll-arrow button. */
     1260      UITOOLS95_DrawRectEdge( dc, r, EDGE_RAISED, (uFlags&DFCS_ADJUSTRECT) | BF_MIDDLE | BF_RECT);
     1261    else
     1262      UITOOLS95_DFC_ButtonPush(dc, r, (uFlags & 0xff00) );
    12451263
    12461264    if(uFlags & DFCS_INACTIVE)
     
    12531271    }
    12541272
    1255     for(i = 0; i < 3; i++)
    1256     {
     1273    if( (uFlags & DFCS_INACTIVE) || !(uFlags & DFCS_PUSHED) )
     1274      for(i = 0; i < 3; i++)
     1275      {
    12571276        Line[i].x--;
    12581277        Line[i].y--;
    1259     }
     1278      }
    12601279
    12611280    i = uFlags & DFCS_INACTIVE ? COLOR_BTNSHADOW : COLOR_BTNTEXT;
Note: See TracChangeset for help on using the changeset viewer.