Hi, More cleanup laying the foundation of unifiying all the drawing code (thumb moving with non moving and win31 with win9x) so that there is a single drawing routine Changelog: scrollbar.c - group the window 31 arrows Use patch -p1 from within the top level wine directory to apply Licence: X11 Andrew.--- wine-20030219/controls/scroll.c 2003-02-27 14:29:38.000000000 +0800 +++ wine/controls/scroll.c 2003-02-27 14:21:46.000000000 +0800 @@ -30,6 +30,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(scroll); +/********************************************************************* + * scrollbar state + * + * Lives as long as the scroll bar + */ typedef struct { INT curVal; /* Current scroll-bar value */ @@ -40,46 +45,29 @@ } SCROLLBAR_INFO, *LPSCROLLBAR_INFO; -static HBITMAP hUpArrow; -static HBITMAP hDnArrow; -static HBITMAP hLfArrow; -static HBITMAP hRgArrow; -static HBITMAP hUpArrowD; -static HBITMAP hDnArrowD; -static HBITMAP hLfArrowD; -static HBITMAP hRgArrowD; -static HBITMAP hUpArrowI; -static HBITMAP hDnArrowI; -static HBITMAP hLfArrowI; -static HBITMAP hRgArrowI; - -#define TOP_ARROW(flags,pressed) \ - (((flags)&ESB_DISABLE_UP) ? hUpArrowI : ((pressed) ? hUpArrowD:hUpArrow)) -#define BOTTOM_ARROW(flags,pressed) \ - (((flags)&ESB_DISABLE_DOWN) ? hDnArrowI : ((pressed) ? hDnArrowD:hDnArrow)) -#define LEFT_ARROW(flags,pressed) \ - (((flags)&ESB_DISABLE_LEFT) ? hLfArrowI : ((pressed) ? hLfArrowD:hLfArrow)) -#define RIGHT_ARROW(flags,pressed) \ - (((flags)&ESB_DISABLE_RIGHT) ? hRgArrowI : ((pressed) ? hRgArrowD:hRgArrow)) - - - /* Minimum size of the rectangle between the arrows */ -#define SCROLL_MIN_RECT 4 - - /* Minimum size of the thumb in pixels */ -#define SCROLL_MIN_THUMB 6 +/********************************************************************* + * scrollbar arrow states + * + * Used in 3.1 mode for arrow images + */ +typedef struct +{ + HBITMAP normal; /* arrow for normal state (unpressed) */ + HBITMAP pressed; /* arrow for pressed state */ + HBITMAP disabled; /* arrow for disabled state */ +} SCROLL_ARROWS, *LPSCROLL_ARROWS; + +#define SCROLL_MIN_RECT 4 /* Minimum size of rectangle between arrows */ +#define SCROLL_MIN_THUMB 6 /* Minimum size of the thumb in pixels */ +#define SCROLL_FIRST_DELAY 200 /* Delay (in ms) before first repetition */ +#define SCROLL_REPEAT_DELAY 50 /* Delay (in ms) between scroll repetitions */ +#define SCROLL_TIMER 0 /* Scroll timer id */ /* Overlap between arrows and thumb */ #define SCROLL_ARROW_THUMB_OVERLAP ((TWEAK_WineLook == WIN31_LOOK) ? 1 : 0) - /* Delay (in ms) before first repetition when holding the button down */ -#define SCROLL_FIRST_DELAY 200 - - /* Delay (in ms) between scroll repetitions */ -#define SCROLL_REPEAT_DELAY 50 - - /* Scroll timer id */ -#define SCROLL_TIMER 0 +#define GET_ARROW(arrow, inactive, press) \ + ((inactive) ? (arrow)->disabled : ((press) ? (arrow)->pressed: (arrow)->normal)) /* Determine if the info is valid */ #define SCROLL_INFO_INVALID(info) \ @@ -87,6 +75,15 @@ ((info->cbSize != sizeof(*info)) && \ (info->cbSize != sizeof(*info) - sizeof(info->nTrackPos)))) + +/********************************************************************* + * scrollbar arrow collections (used by Win 31 only) + */ +static SCROLL_ARROWS hUp; /* Arrow images for up arrow */ +static SCROLL_ARROWS hDown; /* Arrow images for down arrow */ +static SCROLL_ARROWS hLeft; /* Arrow images for left arrow */ +static SCROLL_ARROWS hRight; /* Arrow images for right arrow */ + /* Scroll-bar hit testing */ enum SCROLL_HITTEST { @@ -142,28 +139,45 @@ /*********************************************************************** * SCROLL_LoadBitmaps + * + * Setup the arrow collections. + * + * NOTE: + * Should be called in a libary set up phase rather than SCROLL_DrawArrow + * Also if the OEM numbers follow a matmatical pattern it can be made neater + * Currently called once in Win31 emulating if a scroll bar arrow is drawn */ static void SCROLL_LoadBitmaps(void) { - hUpArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROW) ); - hDnArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROW) ); - hLfArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROW) ); - hRgArrow = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROW) ); - hUpArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWD) ); - hDnArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWD) ); - hLfArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWD) ); - hRgArrowD = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWD) ); - hUpArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_UPARROWI) ); - hDnArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_DNARROWI) ); - hLfArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_LFARROWI) ); - hRgArrowI = LoadBitmapA( 0, MAKEINTRESOURCEA(OBM_RGARROWI) ); + hUp.normal = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_UPARROW)); + hUp.pressed = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_UPARROWD)); + hUp.disabled = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_UPARROWI)); + + hDown.normal = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_DNARROW)); + hDown.pressed = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_DNARROWD)); + hDown.disabled = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_DNARROWI)); + + hLeft.normal = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_LFARROW)); + hLeft.pressed = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_LFARROWD)); + hLeft.disabled = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_LFARROWI)); + + hRight.normal = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_RGARROW)); + hRight.pressed = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_RGARROWD)); + hRight.disabled = LoadBitmapA(0, MAKEINTRESOURCEA(OBM_RGARROWI)); } /*********************************************************************** * SCROLL_GetScrollInfo + * + * Get the scoll info structure for the scroll bar + * + * RETURNS + * Scroll info pointer */ -static SCROLLBAR_INFO *SCROLL_GetScrollInfo( HWND hwnd, INT nBar ) +LPSCROLLBAR_INFO SCROLL_GetScrollInfo( +HWND hwnd /* [in] Handle of window with scrollbar(s) */, +INT nBar /* [in] One of SB_HORZ, SB_VERT, SB_BOTH or SB_CTL */) { SCROLLBAR_INFO *infoPtr; WND *wndPtr = WIN_FindWndPtr( hwnd ); @@ -189,7 +203,7 @@ if (nBar == SB_HORZ) wndPtr->pHScroll = infoPtr; else wndPtr->pVScroll = infoPtr; } - if (!hUpArrow) SCROLL_LoadBitmaps(); + if (!hUp.normal) SCROLL_LoadBitmaps(); } WIN_ReleaseWndPtr( wndPtr ); return infoPtr; @@ -453,9 +467,8 @@ BOOL top_pressed, BOOL bottom_pressed ) { HDC hdcMem = CreateCompatibleDC( hdc ); - HBITMAP hbmpPrev = SelectObject( hdcMem, vertical ? - TOP_ARROW(infoPtr->flags, top_pressed) - : LEFT_ARROW(infoPtr->flags, top_pressed)); + HBITMAP hbmpPrev = SelectObject( hdcMem, GET_ARROW(vertical ? &hUp : &hLeft, + infoPtr->flags & ESB_DISABLE_UP, top_pressed)); SetStretchBltMode( hdc, STRETCH_DELETESCANS ); StretchBlt( hdc, rect->left, rect->top, @@ -465,9 +478,9 @@ GetSystemMetrics(SM_CXVSCROLL),GetSystemMetrics(SM_CYHSCROLL), SRCCOPY ); - SelectObject( hdcMem, vertical ? - BOTTOM_ARROW( infoPtr->flags, bottom_pressed ) - : RIGHT_ARROW( infoPtr->flags, bottom_pressed ) ); + SelectObject( hdcMem, GET_ARROW(vertical ? &hDown : &hRight, + infoPtr->flags & ESB_DISABLE_DOWN, bottom_pressed)); + if (vertical) StretchBlt( hdc, rect->left, rect->bottom - arrowSize, rect->right - rect->left, arrowSize,