Scroll cleanup part 3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:
    scrollbar.c - group the window 31 arrows

The patch was developed without CVS access use patch -p1 from within
the top level wine directory to apply

Licence: X11

Andrew.

--- wine-20020904/controls/scroll.c	Tue Oct  8 18:06:20 2002
+++ wine/controls/scroll.c	Tue Oct  8 18:44:06 2002
@@ -44,52 +44,46 @@
 	UINT flags;            /* EnableScrollBar flags */
 } SCROLLBAR_INFO, *LPSCROLLBAR_INFO;
 
+
+/*********************************************************************
+ * 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 */
+
+#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) \
 	((info->fMask & ~(SIF_ALL | SIF_DISABLENOSCROLL)) || \
 	((info->cbSize != sizeof(*info)) && \
 	(info->cbSize != sizeof(*info) - sizeof(info->nTrackPos))))
 
-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
-
   /* 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
+/*********************************************************************
+ * 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 timer id */
-#define SCROLL_TIMER   0
 
   /* Scroll-bar hit testing */
 enum SCROLL_HITTEST
@@ -146,21 +140,31 @@
 
 /***********************************************************************
  *           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 draw
  */
 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));
 }
 
 
@@ -471,11 +475,10 @@
 				  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));
 
-    if (!hUpArrow) SCROLL_LoadBitmaps();
+    if (!hUp.normal) SCROLL_LoadBitmaps();
     SetStretchBltMode( hdc, STRETCH_DELETESCANS );
     StretchBlt( hdc, rect->left, rect->top,
                   vertical ? rect->right-rect->left : arrowSize,
@@ -484,9 +487,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,



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux