ReactOS  0.4.13-dev-563-g0561610
updown.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "commctrl.h"
#include "comctl32.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "wine/heap.h"
#include "wine/unicode.h"
#include "wine/debug.h"
Include dependency graph for updown.c:

Go to the source code of this file.

Classes

struct  UPDOWN_INFO
 

Macros

#define INITIAL_DELAY   500 /* initial timer until auto-inc kicks in */
 
#define AUTOPRESS_DELAY   250 /* time to keep arrow pressed on KEY_DOWN */
 
#define REPEAT_DELAY   50 /* delay between auto-increments */
 
#define DEFAULT_WIDTH   16 /* default width of the ctrl */
 
#define DEFAULT_XSEP   0 /* default separation between buddy and ctrl */
 
#define DEFAULT_ADDTOP   0 /* amount to extend above the buddy window */
 
#define DEFAULT_ADDBOT   0 /* amount to extend below the buddy window */
 
#define DEFAULT_BUDDYBORDER   2 /* Width/height of the buddy border */
 
#define DEFAULT_BUDDYSPACER   2 /* Spacer between the buddy and the ctrl */
 
#define DEFAULT_BUDDYBORDER_THEMED   1 /* buddy border when theming is enabled */
 
#define DEFAULT_BUDDYSPACER_THEMED   0 /* buddy spacer when theming is enabled */
 
#define FLAG_INCR   0x01
 
#define FLAG_DECR   0x02
 
#define FLAG_MOUSEIN   0x04
 
#define FLAG_PRESSED   0x08
 
#define FLAG_BUDDYINT   0x10 /* UDS_SETBUDDYINT was set on creation */
 
#define FLAG_ARROW   (FLAG_INCR | FLAG_DECR)
 
#define BUDDY_TYPE_UNKNOWN   0
 
#define BUDDY_TYPE_LISTBOX   1
 
#define BUDDY_TYPE_EDIT   2
 
#define TIMER_AUTOREPEAT   1
 
#define TIMER_ACCEL   2
 
#define TIMER_AUTOPRESS   3
 
#define UPDOWN_GetInfoPtr(hwnd)   ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0))
 
#define BUDDY_SUBCLASSID   1
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (updown)
 
static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action)
 
static BOOL UPDOWN_IsBuddyEdit (const UPDOWN_INFO *infoPtr)
 
static BOOL UPDOWN_IsBuddyListbox (const UPDOWN_INFO *infoPtr)
 
static BOOL UPDOWN_InBounds (const UPDOWN_INFO *infoPtr, int val)
 
static BOOL UPDOWN_OffsetVal (UPDOWN_INFO *infoPtr, int delta)
 
static BOOL UPDOWN_HasBuddyBorder (const UPDOWN_INFO *infoPtr)
 
static void UPDOWN_GetArrowRect (const UPDOWN_INFO *infoPtr, RECT *rect, int arrow)
 
static INT UPDOWN_GetArrowFromPoint (const UPDOWN_INFO *infoPtr, RECT *rect, POINT pt)
 
static WCHAR UPDOWN_GetThousandSep (void)
 
static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
 
static BOOL UPDOWN_SetBuddyInt (const UPDOWN_INFO *infoPtr)
 
static BOOL UPDOWN_DrawBuddyBackground (const UPDOWN_INFO *infoPtr, HDC hdc)
 
static LRESULT UPDOWN_Draw (const UPDOWN_INFO *infoPtr, HDC hdc)
 
static LRESULT UPDOWN_Paint (const UPDOWN_INFO *infoPtr, HDC hdc)
 
static LRESULT UPDOWN_KeyPressed (UPDOWN_INFO *infoPtr, int key)
 
static int UPDOWN_GetPos (UPDOWN_INFO *infoPtr, BOOL *err)
 
static int UPDOWN_SetPos (UPDOWN_INFO *infoPtr, int pos)
 
static LRESULT UPDOWN_SetRange (UPDOWN_INFO *infoPtr, INT Max, INT Min)
 
static LRESULT UPDOWN_MouseWheel (UPDOWN_INFO *infoPtr, WPARAM wParam)
 
static LRESULT CALLBACK UPDOWN_Buddy_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uId, DWORD_PTR ref_data)
 
static void UPDOWN_ResetSubclass (UPDOWN_INFO *infoPtr)
 
static HWND UPDOWN_SetBuddy (UPDOWN_INFO *infoPtr, HWND bud)
 
static BOOL UPDOWN_IsEnabled (const UPDOWN_INFO *infoPtr)
 
static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr)
 
static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
 
static LRESULT WINAPI UpDownWindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
void UPDOWN_Register (void)
 
void UPDOWN_Unregister (void)
 

Macro Definition Documentation

◆ AUTOPRESS_DELAY

#define AUTOPRESS_DELAY   250 /* time to keep arrow pressed on KEY_DOWN */

Definition at line 62 of file updown.c.

◆ BUDDY_SUBCLASSID

#define BUDDY_SUBCLASSID   1

Definition at line 94 of file updown.c.

◆ BUDDY_TYPE_EDIT

#define BUDDY_TYPE_EDIT   2

Definition at line 85 of file updown.c.

◆ BUDDY_TYPE_LISTBOX

#define BUDDY_TYPE_LISTBOX   1

Definition at line 84 of file updown.c.

◆ BUDDY_TYPE_UNKNOWN

#define BUDDY_TYPE_UNKNOWN   0

Definition at line 83 of file updown.c.

◆ DEFAULT_ADDBOT

#define DEFAULT_ADDBOT   0 /* amount to extend below the buddy window */

Definition at line 68 of file updown.c.

◆ DEFAULT_ADDTOP

#define DEFAULT_ADDTOP   0 /* amount to extend above the buddy window */

Definition at line 67 of file updown.c.

◆ DEFAULT_BUDDYBORDER

#define DEFAULT_BUDDYBORDER   2 /* Width/height of the buddy border */

Definition at line 69 of file updown.c.

◆ DEFAULT_BUDDYBORDER_THEMED

#define DEFAULT_BUDDYBORDER_THEMED   1 /* buddy border when theming is enabled */

Definition at line 71 of file updown.c.

◆ DEFAULT_BUDDYSPACER

#define DEFAULT_BUDDYSPACER   2 /* Spacer between the buddy and the ctrl */

Definition at line 70 of file updown.c.

◆ DEFAULT_BUDDYSPACER_THEMED

#define DEFAULT_BUDDYSPACER_THEMED   0 /* buddy spacer when theming is enabled */

Definition at line 72 of file updown.c.

◆ DEFAULT_WIDTH

#define DEFAULT_WIDTH   16 /* default width of the ctrl */

Definition at line 65 of file updown.c.

◆ DEFAULT_XSEP

#define DEFAULT_XSEP   0 /* default separation between buddy and ctrl */

Definition at line 66 of file updown.c.

◆ FLAG_ARROW

#define FLAG_ARROW   (FLAG_INCR | FLAG_DECR)

Definition at line 81 of file updown.c.

◆ FLAG_BUDDYINT

#define FLAG_BUDDYINT   0x10 /* UDS_SETBUDDYINT was set on creation */

Definition at line 80 of file updown.c.

◆ FLAG_DECR

#define FLAG_DECR   0x02

Definition at line 77 of file updown.c.

◆ FLAG_INCR

#define FLAG_INCR   0x01

Definition at line 76 of file updown.c.

◆ FLAG_MOUSEIN

#define FLAG_MOUSEIN   0x04

Definition at line 78 of file updown.c.

◆ FLAG_PRESSED

#define FLAG_PRESSED   0x08

Definition at line 79 of file updown.c.

◆ INITIAL_DELAY

#define INITIAL_DELAY   500 /* initial timer until auto-inc kicks in */

Definition at line 61 of file updown.c.

◆ REPEAT_DELAY

#define REPEAT_DELAY   50 /* delay between auto-increments */

Definition at line 63 of file updown.c.

◆ TIMER_ACCEL

#define TIMER_ACCEL   2

Definition at line 88 of file updown.c.

◆ TIMER_AUTOPRESS

#define TIMER_AUTOPRESS   3

Definition at line 89 of file updown.c.

◆ TIMER_AUTOREPEAT

#define TIMER_AUTOREPEAT   1

Definition at line 87 of file updown.c.

◆ UPDOWN_GetInfoPtr

#define UPDOWN_GetInfoPtr (   hwnd)    ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0))

Definition at line 91 of file updown.c.

Function Documentation

◆ UPDOWN_Buddy_SubclassProc()

static LRESULT CALLBACK UPDOWN_Buddy_SubclassProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
UINT_PTR  uId,
DWORD_PTR  ref_data 
)
static

Definition at line 574 of file updown.c.

576 {
577  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr((HWND)ref_data);
578 
579  TRACE("hwnd=%p, uMsg=%04x, wParam=%08lx, lParam=%08lx\n",
580  hwnd, uMsg, wParam, lParam);
581 
582  switch(uMsg)
583  {
584  case WM_KEYDOWN:
585  if (infoPtr)
586  {
587  UPDOWN_KeyPressed(infoPtr, (int)wParam);
588  if (wParam == VK_UP || wParam == VK_DOWN)
589  return 0;
590  }
591  break;
592 
593  case WM_MOUSEWHEEL:
594  if (infoPtr)
595  UPDOWN_MouseWheel(infoPtr, (int)wParam);
596  break;
597 
598  case WM_NCDESTROY:
600  break;
601  default:
602  break;
603  }
604 
606 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define VK_DOWN
Definition: winuser.h:2181
WPARAM wParam
Definition: combotst.c:138
#define UPDOWN_GetInfoPtr(hwnd)
Definition: updown.c:91
#define VK_UP
Definition: winuser.h:2179
#define WM_KEYDOWN
Definition: winuser.h:1691
LRESULT WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: commctrl.c:1496
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_NCDESTROY
Definition: winuser.h:1666
#define BUDDY_SUBCLASSID
Definition: updown.c:94
static LRESULT UPDOWN_MouseWheel(UPDOWN_INFO *infoPtr, WPARAM wParam)
Definition: updown.c:552
BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
Definition: commctrl.c:1390
static LRESULT CALLBACK UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uId, DWORD_PTR ref_data)
Definition: updown.c:574
LPARAM lParam
Definition: combotst.c:139
static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
Definition: updown.c:463

Referenced by UPDOWN_ResetSubclass(), and UPDOWN_SetBuddy().

◆ UPDOWN_CancelMode()

static BOOL UPDOWN_CancelMode ( UPDOWN_INFO infoPtr)
static

Definition at line 776 of file updown.c.

777 {
778  if (!(infoPtr->Flags & FLAG_PRESSED)) return FALSE;
779 
780  KillTimer (infoPtr->Self, TIMER_AUTOREPEAT);
781  KillTimer (infoPtr->Self, TIMER_ACCEL);
782  KillTimer (infoPtr->Self, TIMER_AUTOPRESS);
783 
784  if (GetCapture() == infoPtr->Self) {
785  NMHDR hdr;
786  hdr.hwndFrom = infoPtr->Self;
787  hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
788  hdr.code = NM_RELEASEDCAPTURE;
789  SendMessageW(infoPtr->Notify, WM_NOTIFY, hdr.idFrom, (LPARAM)&hdr);
790  ReleaseCapture();
791  }
792 
793  infoPtr->Flags &= ~FLAG_PRESSED;
794  InvalidateRect (infoPtr->Self, NULL, FALSE);
795 
796  return TRUE;
797 }
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
#define TIMER_AUTOREPEAT
Definition: updown.c:87
#define NM_RELEASEDCAPTURE
Definition: commctrl.h:141
#define GetWindowLongPtrW
Definition: winuser.h:4698
#define TIMER_AUTOPRESS
Definition: updown.c:89
#define FLAG_PRESSED
Definition: updown.c:79
HWND WINAPI GetCapture(void)
Definition: message.c:2879
HWND Self
Definition: updown.c:43
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
HWND Notify
Definition: updown.c:44
#define GWLP_ID
Definition: winuser.h:854
#define WM_NOTIFY
Definition: richedit.h:61
#define TIMER_ACCEL
Definition: updown.c:88
INT Flags
Definition: updown.c:55

Referenced by UpDownWindowProc().

◆ UPDOWN_DoAction()

static void UPDOWN_DoAction ( UPDOWN_INFO infoPtr,
int  delta,
int  action 
)
static

Definition at line 718 of file updown.c.

719 {
720  NM_UPDOWN ni;
721 
722  TRACE("%d by %d\n", action, delta);
723 
724  /* check if we can do the modification first */
725  delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1);
726  if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0;
727 
728  TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta);
729 
730  /* We must notify parent now to obtain permission */
731  ni.iPos = infoPtr->CurVal;
732  ni.iDelta = delta;
733  ni.hdr.hwndFrom = infoPtr->Self;
734  ni.hdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
735  ni.hdr.code = UDN_DELTAPOS;
736  if (!SendMessageW(infoPtr->Notify, WM_NOTIFY, ni.hdr.idFrom, (LPARAM)&ni)) {
737  /* Parent said: OK to adjust */
738 
739  /* Now adjust value with (maybe new) delta */
740  if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) {
741  TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta);
742 
743  /* Now take care about our buddy */
744  UPDOWN_SetBuddyInt (infoPtr);
745  }
746  }
747 
748  /* Also, notify it. This message is sent in any case. */
749  SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
750  MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), (LPARAM)infoPtr->Self);
751 }
INT CurVal
Definition: updown.c:50
static BOOL UPDOWN_OffsetVal(UPDOWN_INFO *infoPtr, int delta)
Definition: updown.c:134
static struct netconfig_info ni
Definition: getnetconfig.c:158
INT MaxVal
Definition: updown.c:52
#define GetWindowLongPtrW
Definition: winuser.h:4698
DWORD dwStyle
Definition: updown.c:45
#define MAKELONG(a, b)
Definition: typedefs.h:248
HWND Self
Definition: updown.c:43
#define SB_THUMBPOSITION
Definition: winuser.h:572
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL UPDOWN_SetBuddyInt(const UPDOWN_INFO *infoPtr)
Definition: updown.c:305
#define FLAG_DECR
Definition: updown.c:77
#define UDN_DELTAPOS
Definition: commctrl.h:2141
#define UDS_HORZ
Definition: commctrl.h:2109
#define NM_UPDOWN
Definition: commctrl.h:2132
const WCHAR * action
Definition: action.c:7783
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_HSCROLL
Definition: winuser.h:1719
INT MinVal
Definition: updown.c:51
#define FLAG_INCR
Definition: updown.c:76
HWND Notify
Definition: updown.c:44
#define GWLP_ID
Definition: winuser.h:854
#define WM_NOTIFY
Definition: richedit.h:61
#define WM_VSCROLL
Definition: winuser.h:1720

Referenced by UPDOWN_HandleMouseEvent(), UPDOWN_KeyPressed(), UPDOWN_MouseWheel(), and UpDownWindowProc().

◆ UPDOWN_Draw()

static LRESULT UPDOWN_Draw ( const UPDOWN_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 381 of file updown.c.

382 {
383  BOOL uPressed, uHot, dPressed, dHot;
384  RECT rect;
385  HTHEME theme = GetWindowTheme (infoPtr->Self);
386  int uPart = 0, uState = 0, dPart = 0, dState = 0;
387  BOOL needBuddyBg = FALSE;
388 
389  uPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR);
390  uHot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN);
391  dPressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR);
392  dHot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN);
393  if (theme) {
394  uPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_UPHORZ : SPNP_UP;
395  uState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
396  : (uPressed ? DNS_PRESSED : (uHot ? DNS_HOT : DNS_NORMAL));
397  dPart = (infoPtr->dwStyle & UDS_HORZ) ? SPNP_DOWNHORZ : SPNP_DOWN;
398  dState = (infoPtr->dwStyle & WS_DISABLED) ? DNS_DISABLED
399  : (dPressed ? DNS_PRESSED : (dHot ? DNS_HOT : DNS_NORMAL));
400  needBuddyBg = IsWindow (infoPtr->Buddy)
401  && (IsThemeBackgroundPartiallyTransparent (theme, uPart, uState)
402  || IsThemeBackgroundPartiallyTransparent (theme, dPart, dState));
403  }
404 
405  /* Draw the common border between ourselves and our buddy */
406  if (UPDOWN_HasBuddyBorder(infoPtr) || needBuddyBg) {
407  if (!theme || !UPDOWN_DrawBuddyBackground (infoPtr, hdc)) {
408  GetClientRect(infoPtr->Self, &rect);
410  BF_BOTTOM | BF_TOP |
411  (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT));
412  }
413  }
414 
415  /* Draw the incr button */
416  UPDOWN_GetArrowRect (infoPtr, &rect, FLAG_INCR);
417  if (theme) {
418  DrawThemeBackground(theme, hdc, uPart, uState, &rect, NULL);
419  } else {
422  ((infoPtr->dwStyle & UDS_HOTTRACK) && uHot ? DFCS_HOT : 0) |
423  (uPressed ? DFCS_PUSHED : 0) |
424  (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
425  }
426 
427  /* Draw the decr button */
428  UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR);
429  if (theme) {
430  DrawThemeBackground(theme, hdc, dPart, dState, &rect, NULL);
431  } else {
434  ((infoPtr->dwStyle & UDS_HOTTRACK) && dHot ? DFCS_HOT : 0) |
435  (dPressed ? DFCS_PUSHED : 0) |
436  (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
437  }
438 
439  return 0;
440 }
#define WS_DISABLED
Definition: pedump.c:621
#define UDS_ALIGNLEFT
Definition: commctrl.h:2106
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define DFCS_INACTIVE
Definition: winuser.h:502
#define BF_BOTTOM
Definition: winuser.h:457
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
DWORD dwStyle
Definition: updown.c:45
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1883
#define DFCS_PUSHED
Definition: winuser.h:503
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FLAG_PRESSED
Definition: updown.c:79
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
HWND Self
Definition: updown.c:43
smooth NULL
Definition: ftsmooth.c:416
#define DFCS_SCROLLDOWN
Definition: winuser.h:490
#define FLAG_MOUSEIN
Definition: updown.c:78
#define BF_RIGHT
Definition: winuser.h:456
#define DFCS_SCROLLRIGHT
Definition: winuser.h:492
static void UPDOWN_GetArrowRect(const UPDOWN_INFO *infoPtr, RECT *rect, int arrow)
Definition: updown.c:175
#define FLAG_DECR
Definition: updown.c:77
#define DFCS_SCROLLUP
Definition: winuser.h:489
static BOOL UPDOWN_DrawBuddyBackground(const UPDOWN_INFO *infoPtr, HDC hdc)
Definition: updown.c:357
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
HDC hdc
Definition: main.c:9
#define UDS_HORZ
Definition: commctrl.h:2109
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define BF_TOP
Definition: winuser.h:455
static BOOL UPDOWN_HasBuddyBorder(const UPDOWN_INFO *infoPtr)
Definition: updown.c:161
#define DFC_SCROLL
Definition: winuser.h:475
HWND Buddy
Definition: updown.c:53
#define FLAG_INCR
Definition: updown.c:76
#define EDGE_SUNKEN
Definition: winuser.h:451
#define UDS_HOTTRACK
Definition: commctrl.h:2111
#define DFCS_SCROLLLEFT
Definition: winuser.h:491
#define BF_LEFT
Definition: winuser.h:454
INT Flags
Definition: updown.c:55

Referenced by UPDOWN_Paint().

◆ UPDOWN_DrawBuddyBackground()

static BOOL UPDOWN_DrawBuddyBackground ( const UPDOWN_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 357 of file updown.c.

358 {
359  RECT br, r;
360  HTHEME buddyTheme = GetWindowTheme (infoPtr->Buddy);
361  if (!buddyTheme) return FALSE;
362 
363  GetWindowRect (infoPtr->Buddy, &br);
364  MapWindowPoints (NULL, infoPtr->Self, (POINT*)&br, 2);
365  GetClientRect (infoPtr->Self, &r);
366 
367  if (infoPtr->dwStyle & UDS_ALIGNLEFT)
368  br.left = r.left;
369  else if (infoPtr->dwStyle & UDS_ALIGNRIGHT)
370  br.right = r.right;
371  /* FIXME: take disabled etc. into account */
372  DrawThemeBackground (buddyTheme, hdc, 0, 0, &br, NULL);
373  return TRUE;
374 }
#define TRUE
Definition: types.h:120
#define UDS_ALIGNLEFT
Definition: commctrl.h:2106
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
DWORD dwStyle
Definition: updown.c:45
HWND Self
Definition: updown.c:43
smooth NULL
Definition: ftsmooth.c:416
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
HDC hdc
Definition: main.c:9
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define UDS_ALIGNRIGHT
Definition: commctrl.h:2105
HWND Buddy
Definition: updown.c:53
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by UPDOWN_Draw().

◆ UPDOWN_GetArrowFromPoint()

static INT UPDOWN_GetArrowFromPoint ( const UPDOWN_INFO infoPtr,
RECT rect,
POINT  pt 
)
static

Definition at line 227 of file updown.c.

228 {
229  UPDOWN_GetArrowRect (infoPtr, rect, FLAG_INCR);
230  if(PtInRect(rect, pt)) return FLAG_INCR;
231 
232  UPDOWN_GetArrowRect (infoPtr, rect, FLAG_DECR);
233  if(PtInRect(rect, pt)) return FLAG_DECR;
234 
235  return 0;
236 }
#define pt(x, y)
Definition: drawing.c:79
& rect
Definition: startmenu.cpp:1413
static void UPDOWN_GetArrowRect(const UPDOWN_INFO *infoPtr, RECT *rect, int arrow)
Definition: updown.c:175
#define FLAG_DECR
Definition: updown.c:77
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define FLAG_INCR
Definition: updown.c:76

Referenced by UPDOWN_HandleMouseEvent().

◆ UPDOWN_GetArrowRect()

static void UPDOWN_GetArrowRect ( const UPDOWN_INFO infoPtr,
RECT rect,
int  arrow 
)
static

Definition at line 175 of file updown.c.

176 {
177  HTHEME theme = GetWindowTheme (infoPtr->Self);
179  const int spacer = theme ? DEFAULT_BUDDYSPACER_THEMED : DEFAULT_BUDDYSPACER;
180  GetClientRect (infoPtr->Self, rect);
181 
182  /*
183  * Make sure we calculate the rectangle to fit even if we draw the
184  * border.
185  */
186  if (UPDOWN_HasBuddyBorder(infoPtr)) {
187  if (infoPtr->dwStyle & UDS_ALIGNLEFT)
188  rect->left += border;
189  else
190  rect->right -= border;
191 
192  InflateRect(rect, 0, -border);
193  }
194 
195  /* now figure out if we need a space away from the buddy */
196  if (IsWindow(infoPtr->Buddy) ) {
197  if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->right -= spacer;
198  else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) rect->left += spacer;
199  }
200 
201  /*
202  * We're calculating the midpoint to figure-out where the
203  * separation between the buttons will lay. We make sure that we
204  * round the uneven numbers by adding 1.
205  */
206  if (infoPtr->dwStyle & UDS_HORZ) {
207  int len = rect->right - rect->left + 1; /* compute the width */
208  if (arrow & FLAG_INCR)
209  rect->left = rect->left + len/2;
210  if (arrow & FLAG_DECR)
211  rect->right = rect->left + len/2 - (theme ? 0 : 1);
212  } else {
213  int len = rect->bottom - rect->top + 1; /* compute the height */
214  if (arrow & FLAG_INCR)
215  rect->bottom = rect->top + len/2 - (theme ? 0 : 1);
216  if (arrow & FLAG_DECR)
217  rect->top = rect->top + len/2;
218  }
219 }
#define DEFAULT_BUDDYSPACER
Definition: updown.c:70
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define UDS_ALIGNLEFT
Definition: commctrl.h:2106
#define DEFAULT_BUDDYBORDER
Definition: updown.c:69
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define DEFAULT_BUDDYSPACER_THEMED
Definition: updown.c:72
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
DWORD dwStyle
Definition: updown.c:45
& rect
Definition: startmenu.cpp:1413
HWND Self
Definition: updown.c:43
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
#define FLAG_DECR
Definition: updown.c:77
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
GLenum GLsizei len
Definition: glext.h:6722
#define UDS_HORZ
Definition: commctrl.h:2109
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define UDS_ALIGNRIGHT
Definition: commctrl.h:2105
static BOOL UPDOWN_HasBuddyBorder(const UPDOWN_INFO *infoPtr)
Definition: updown.c:161
#define DEFAULT_BUDDYBORDER_THEMED
Definition: updown.c:71
HWND Buddy
Definition: updown.c:53
#define FLAG_INCR
Definition: updown.c:76

Referenced by UPDOWN_Draw(), and UPDOWN_GetArrowFromPoint().

◆ UPDOWN_GetBuddyInt()

static BOOL UPDOWN_GetBuddyInt ( UPDOWN_INFO infoPtr)
static

Definition at line 261 of file updown.c.

262 {
263  WCHAR txt[20], sep, *src, *dst;
264  int newVal;
265 
266  if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
267  return FALSE;
268 
269  /*if the buddy is a list window, we must set curr index */
270  if (UPDOWN_IsBuddyListbox(infoPtr)) {
271  newVal = SendMessageW(infoPtr->Buddy, LB_GETCARETINDEX, 0, 0);
272  if(newVal < 0) return FALSE;
273  } else {
274  /* we have a regular window, so will get the text */
275  /* note that a zero-length string is a legitimate value for 'txt',
276  * and ought to result in a successful conversion to '0'. */
277  if (GetWindowTextW(infoPtr->Buddy, txt, ARRAY_SIZE(txt)) < 0)
278  return FALSE;
279 
280  sep = UPDOWN_GetThousandSep();
281 
282  /* now get rid of the separators */
283  for(src = dst = txt; *src; src++)
284  if(*src != sep) *dst++ = *src;
285  *dst = 0;
286 
287  /* try to convert the number and validate it */
288  newVal = strtolW(txt, &src, infoPtr->Base);
289  if(*src || !UPDOWN_InBounds (infoPtr, newVal)) return FALSE;
290  }
291 
292  TRACE("new value(%d) from buddy (old=%d)\n", newVal, infoPtr->CurVal);
293  infoPtr->CurVal = newVal;
294  return TRUE;
295 }
#define TRUE
Definition: types.h:120
INT CurVal
Definition: updown.c:50
BOOL WINAPI IsWindow(_In_opt_ HWND)
static BOOL UPDOWN_InBounds(const UPDOWN_INFO *infoPtr, int val)
Definition: updown.c:120
#define strtolW(s, e, b)
Definition: unicode.h:33
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum src
Definition: glext.h:6340
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1378
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCARETINDEX
Definition: winuser.h:1998
GLenum GLenum dst
Definition: glext.h:6340
static WCHAR UPDOWN_GetThousandSep(void)
Definition: updown.c:243
HWND Buddy
Definition: updown.c:53
INT Base
Definition: updown.c:49
static BOOL UPDOWN_IsBuddyListbox(const UPDOWN_INFO *infoPtr)
Definition: updown.c:111
#define FLAG_BUDDYINT
Definition: updown.c:80
INT Flags
Definition: updown.c:55

Referenced by UPDOWN_GetPos(), UPDOWN_HandleMouseEvent(), UPDOWN_KeyPressed(), and UPDOWN_MouseWheel().

◆ UPDOWN_GetPos()

static int UPDOWN_GetPos ( UPDOWN_INFO infoPtr,
BOOL err 
)
static

Definition at line 481 of file updown.c.

482 {
483  BOOL succ = UPDOWN_GetBuddyInt(infoPtr);
484  int val = infoPtr->CurVal;
485 
486  if(!UPDOWN_InBounds(infoPtr, val)) {
487  if((infoPtr->MinVal < infoPtr->MaxVal && val < infoPtr->MinVal)
488  || (infoPtr->MinVal > infoPtr->MaxVal && val > infoPtr->MinVal))
489  val = infoPtr->MinVal;
490  else
491  val = infoPtr->MaxVal;
492 
493  succ = FALSE;
494  }
495 
496  if(err) *err = !succ;
497  return val;
498 }
INT CurVal
Definition: updown.c:50
static BOOL UPDOWN_InBounds(const UPDOWN_INFO *infoPtr, int val)
Definition: updown.c:120
INT MaxVal
Definition: updown.c:52
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint GLfloat * val
Definition: glext.h:7180
#define err(...)
INT MinVal
Definition: updown.c:51
static BOOL UPDOWN_GetBuddyInt(UPDOWN_INFO *infoPtr)
Definition: updown.c:261

Referenced by UpDownWindowProc().

◆ UPDOWN_GetThousandSep()

static WCHAR UPDOWN_GetThousandSep ( void  )
static

Definition at line 243 of file updown.c.

244 {
245  WCHAR sep[2];
246 
248  sep[0] = ',';
249 
250  return sep[0];
251 }
#define LOCALE_USER_DEFAULT
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_STHOUSAND
Definition: winnls.h:43
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by UPDOWN_GetBuddyInt(), and UPDOWN_SetBuddyInt().

◆ UPDOWN_HandleMouseEvent()

static void UPDOWN_HandleMouseEvent ( UPDOWN_INFO infoPtr,
UINT  msg,
INT  x,
INT  y 
)
static

Definition at line 806 of file updown.c.

807 {
808  POINT pt = { x, y };
809  RECT rect;
810  int temp, arrow;
811  TRACKMOUSEEVENT tme;
812 
813  TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt));
814 
815  switch(msg)
816  {
817  case WM_LBUTTONDOWN: /* Initialise mouse tracking */
818 
819  /* If the buddy is an edit, will set focus to it */
820  if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy);
821 
822  /* Now see which one is the 'active' arrow */
823  arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
824 
825  /* Update the flags if we are in/out */
826  infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
827  if (arrow)
828  infoPtr->Flags |= FLAG_MOUSEIN | arrow;
829  else
830  if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
831 
832  if (infoPtr->Flags & FLAG_ARROW) {
833 
834  /* Update the CurVal if necessary */
835  UPDOWN_GetBuddyInt (infoPtr);
836 
837  /* Set up the correct flags */
838  infoPtr->Flags |= FLAG_PRESSED;
839 
840  /* repaint the control */
841  InvalidateRect (infoPtr->Self, NULL, FALSE);
842 
843  /* process the click */
844  temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
845  UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
846 
847  /* now capture all mouse messages */
848  SetCapture (infoPtr->Self);
849 
850  /* and startup the first timer */
852  }
853  break;
854 
855  case WM_MOUSEMOVE:
856  /* save the flags to see if any got modified */
857  temp = infoPtr->Flags;
858 
859  /* Now see which one is the 'active' arrow */
860  arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt);
861 
862  /* Update the flags if we are in/out */
863  infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
864  if(arrow) {
865  infoPtr->Flags |= FLAG_MOUSEIN | arrow;
866  } else {
867  if(infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0;
868  }
869 
870  /* If state changed, redraw the control */
871  if(temp != infoPtr->Flags)
872  InvalidateRect (infoPtr->Self, NULL, FALSE);
873 
874  /* Set up tracking so the mousein flags can be reset when the
875  * mouse leaves the control */
876  tme.cbSize = sizeof( tme );
877  tme.dwFlags = TME_LEAVE;
878  tme.hwndTrack = infoPtr->Self;
879  TrackMouseEvent (&tme);
880 
881  break;
882  case WM_MOUSELEAVE:
883  infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW);
884  InvalidateRect (infoPtr->Self, NULL, FALSE);
885  break;
886 
887  default:
888  ERR("Impossible case (msg=%x)!\n", msg);
889  }
890 
891 }
#define TIMER_AUTOREPEAT
Definition: updown.c:87
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
#define pt(x, y)
Definition: drawing.c:79
static INT UPDOWN_GetArrowFromPoint(const UPDOWN_INFO *infoPtr, RECT *rect, POINT pt)
Definition: updown.c:227
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HWND WINAPI SetFocus(_In_opt_ HWND)
INT AccelIndex
Definition: updown.c:48
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
#define FLAG_PRESSED
Definition: updown.c:79
static BOOL UPDOWN_IsBuddyEdit(const UPDOWN_INFO *infoPtr)
Definition: updown.c:102
#define WM_MOUSELEAVE
Definition: commctrl.h:4946
HWND Self
Definition: updown.c:43
smooth NULL
Definition: ftsmooth.c:416
UINT AccelCount
Definition: updown.c:46
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
const char * wine_dbgstr_point(const POINT *guid)
#define TRACE(s)
Definition: solgame.cpp:4
#define FLAG_MOUSEIN
Definition: updown.c:78
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
UINT nInc
Definition: commctrl.h:2097
#define ERR(fmt,...)
Definition: debug.h:109
#define FLAG_ARROW
Definition: updown.c:81
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define INITIAL_DELAY
Definition: updown.c:61
static calc_node_t temp
Definition: rpn_ieee.c:38
#define TME_LEAVE
Definition: commctrl.h:4952
#define WM_MOUSEMOVE
Definition: winuser.h:1751
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
HWND Buddy
Definition: updown.c:53
#define msg(x)
Definition: auth_time.c:54
UDACCEL * AccelVect
Definition: updown.c:47
static BOOL UPDOWN_GetBuddyInt(UPDOWN_INFO *infoPtr)
Definition: updown.c:261
static void UPDOWN_DoAction(UPDOWN_INFO *infoPtr, int delta, int action)
Definition: updown.c:718
INT Flags
Definition: updown.c:55

Referenced by UpDownWindowProc().

◆ UPDOWN_HasBuddyBorder()

static BOOL UPDOWN_HasBuddyBorder ( const UPDOWN_INFO infoPtr)
static

Definition at line 161 of file updown.c.

162 {
163  return ( ((infoPtr->dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) &&
164  UPDOWN_IsBuddyEdit(infoPtr) );
165 }
#define UDS_ALIGNLEFT
Definition: commctrl.h:2106
DWORD dwStyle
Definition: updown.c:45
static BOOL UPDOWN_IsBuddyEdit(const UPDOWN_INFO *infoPtr)
Definition: updown.c:102
#define UDS_ALIGNRIGHT
Definition: commctrl.h:2105

Referenced by UPDOWN_Draw(), UPDOWN_GetArrowRect(), and UPDOWN_SetBuddy().

◆ UPDOWN_InBounds()

static BOOL UPDOWN_InBounds ( const UPDOWN_INFO infoPtr,
int  val 
)
static

Definition at line 120 of file updown.c.

121 {
122  if(infoPtr->MaxVal > infoPtr->MinVal)
123  return (infoPtr->MinVal <= val) && (val <= infoPtr->MaxVal);
124  else
125  return (infoPtr->MaxVal <= val) && (val <= infoPtr->MinVal);
126 }
INT MaxVal
Definition: updown.c:52
GLuint GLfloat * val
Definition: glext.h:7180
INT MinVal
Definition: updown.c:51

Referenced by UPDOWN_GetBuddyInt(), UPDOWN_GetPos(), UPDOWN_OffsetVal(), and UPDOWN_SetPos().

◆ UPDOWN_IsBuddyEdit()

static BOOL UPDOWN_IsBuddyEdit ( const UPDOWN_INFO infoPtr)
inlinestatic

Definition at line 102 of file updown.c.

103 {
104  return infoPtr->BuddyType == BUDDY_TYPE_EDIT;
105 }
#define BUDDY_TYPE_EDIT
Definition: updown.c:85
INT BuddyType
Definition: updown.c:54

Referenced by UPDOWN_HandleMouseEvent(), UPDOWN_HasBuddyBorder(), and UpDownWindowProc().

◆ UPDOWN_IsBuddyListbox()

static BOOL UPDOWN_IsBuddyListbox ( const UPDOWN_INFO infoPtr)
inlinestatic

Definition at line 111 of file updown.c.

112 {
113  return infoPtr->BuddyType == BUDDY_TYPE_LISTBOX;
114 }
#define BUDDY_TYPE_LISTBOX
Definition: updown.c:84
INT BuddyType
Definition: updown.c:54

Referenced by UPDOWN_GetBuddyInt(), and UPDOWN_SetBuddyInt().

◆ UPDOWN_IsEnabled()

static BOOL UPDOWN_IsEnabled ( const UPDOWN_INFO infoPtr)
static

Definition at line 759 of file updown.c.

760 {
761  if (!IsWindowEnabled(infoPtr->Self))
762  return FALSE;
763  if(infoPtr->Buddy)
764  return IsWindowEnabled(infoPtr->Buddy);
765  return TRUE;
766 }
#define TRUE
Definition: types.h:120
HWND Self
Definition: updown.c:43
BOOL WINAPI IsWindowEnabled(_In_ HWND)
HWND Buddy
Definition: updown.c:53

Referenced by UpDownWindowProc().

◆ UPDOWN_KeyPressed()

static LRESULT UPDOWN_KeyPressed ( UPDOWN_INFO infoPtr,
int  key 
)
static

Definition at line 463 of file updown.c.

464 {
465  int arrow, accel;
466 
467  if (key == VK_UP) arrow = FLAG_INCR;
468  else if (key == VK_DOWN) arrow = FLAG_DECR;
469  else return 1;
470 
471  UPDOWN_GetBuddyInt (infoPtr);
472  infoPtr->Flags &= ~FLAG_ARROW;
473  infoPtr->Flags |= FLAG_PRESSED | arrow;
474  InvalidateRect (infoPtr->Self, NULL, FALSE);
476  accel = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1;
477  UPDOWN_DoAction (infoPtr, accel, arrow);
478  return 0;
479 }
#define VK_DOWN
Definition: winuser.h:2181
#define TIMER_AUTOPRESS
Definition: updown.c:89
#define VK_UP
Definition: winuser.h:2179
#define FLAG_PRESSED
Definition: updown.c:79
HWND Self
Definition: updown.c:43
smooth NULL
Definition: ftsmooth.c:416
UINT AccelCount
Definition: updown.c:46
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define FLAG_DECR
Definition: updown.c:77
UINT nInc
Definition: commctrl.h:2097
#define FLAG_ARROW
Definition: updown.c:81
UDACCEL * AccelVect
Definition: updown.c:47
#define FLAG_INCR
Definition: updown.c:76
static BOOL UPDOWN_GetBuddyInt(UPDOWN_INFO *infoPtr)
Definition: updown.c:261
#define AUTOPRESS_DELAY
Definition: updown.c:62
Definition: path.c:42
static void UPDOWN_DoAction(UPDOWN_INFO *infoPtr, int delta, int action)
Definition: updown.c:718
INT Flags
Definition: updown.c:55

Referenced by UPDOWN_Buddy_SubclassProc(), and UpDownWindowProc().

◆ UPDOWN_MouseWheel()

static LRESULT UPDOWN_MouseWheel ( UPDOWN_INFO infoPtr,
WPARAM  wParam 
)
static

Definition at line 552 of file updown.c.

553 {
554  int iWheelDelta = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
555 
556  if (wParam & (MK_SHIFT | MK_CONTROL))
557  return 0;
558 
559  if (iWheelDelta != 0)
560  {
561  UPDOWN_GetBuddyInt(infoPtr);
562  UPDOWN_DoAction(infoPtr, abs(iWheelDelta), iWheelDelta > 0 ? FLAG_INCR : FLAG_DECR);
563  }
564 
565  return 1;
566 }
#define abs(i)
Definition: fconv.c:206
#define MK_SHIFT
Definition: winuser.h:2323
WPARAM wParam
Definition: combotst.c:138
#define WHEEL_DELTA
Definition: treelist.c:99
#define FLAG_DECR
Definition: updown.c:77
#define MK_CONTROL
Definition: winuser.h:2324
#define FLAG_INCR
Definition: updown.c:76
static BOOL UPDOWN_GetBuddyInt(UPDOWN_INFO *infoPtr)
Definition: updown.c:261
static void UPDOWN_DoAction(UPDOWN_INFO *infoPtr, int delta, int action)
Definition: updown.c:718

Referenced by UPDOWN_Buddy_SubclassProc(), and UpDownWindowProc().

◆ UPDOWN_OffsetVal()

static BOOL UPDOWN_OffsetVal ( UPDOWN_INFO infoPtr,
int  delta 
)
static

Definition at line 134 of file updown.c.

135 {
136  /* check if we can do the modification first */
137  if(!UPDOWN_InBounds (infoPtr, infoPtr->CurVal+delta)) {
138  if (infoPtr->dwStyle & UDS_WRAP) {
139  delta += (delta < 0 ? -1 : 1) *
140  (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) *
141  (infoPtr->MinVal - infoPtr->MaxVal) +
142  (delta < 0 ? 1 : -1);
143  } else if ((infoPtr->MaxVal > infoPtr->MinVal && infoPtr->CurVal+delta > infoPtr->MaxVal)
144  || (infoPtr->MaxVal < infoPtr->MinVal && infoPtr->CurVal+delta < infoPtr->MaxVal)) {
145  delta = infoPtr->MaxVal - infoPtr->CurVal;
146  } else {
147  delta = infoPtr->MinVal - infoPtr->CurVal;
148  }
149  }
150 
151  infoPtr->CurVal += delta;
152  return delta != 0;
153 }
INT CurVal
Definition: updown.c:50
static BOOL UPDOWN_InBounds(const UPDOWN_INFO *infoPtr, int val)
Definition: updown.c:120
INT MaxVal
Definition: updown.c:52
DWORD dwStyle
Definition: updown.c:45
#define UDS_WRAP
Definition: commctrl.h:2103
INT MinVal
Definition: updown.c:51

Referenced by UPDOWN_DoAction().

◆ UPDOWN_Paint()

static LRESULT UPDOWN_Paint ( const UPDOWN_INFO infoPtr,
HDC  hdc 
)
static

Definition at line 448 of file updown.c.

449 {
450  PAINTSTRUCT ps;
451  if (hdc) return UPDOWN_Draw (infoPtr, hdc);
452  hdc = BeginPaint (infoPtr->Self, &ps);
453  UPDOWN_Draw (infoPtr, hdc);
454  EndPaint (infoPtr->Self, &ps);
455  return 0;
456 }
static LRESULT UPDOWN_Draw(const UPDOWN_INFO *infoPtr, HDC hdc)
Definition: updown.c:381
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HWND Self
Definition: updown.c:43
HDC hdc
Definition: main.c:9

Referenced by UpDownWindowProc().

◆ UPDOWN_Register()

void UPDOWN_Register ( void  )

Definition at line 1181 of file updown.c.

1182 {
1183  WNDCLASSW wndClass;
1184 
1185  ZeroMemory( &wndClass, sizeof( WNDCLASSW ) );
1186  wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
1187  wndClass.lpfnWndProc = UpDownWindowProc;
1188  wndClass.cbClsExtra = 0;
1189  wndClass.cbWndExtra = sizeof(UPDOWN_INFO*);
1190  wndClass.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
1191  wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1192  wndClass.lpszClassName = UPDOWN_CLASSW;
1193 
1194  RegisterClassW( &wndClass );
1195 }
UINT style
Definition: winuser.h:3129
#define ZeroMemory
Definition: winbase.h:1635
#define CS_HREDRAW
Definition: winuser.h:648
int cbClsExtra
Definition: winuser.h:3131
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
WNDPROC lpfnWndProc
Definition: winuser.h:3130
LPCWSTR lpszClassName
Definition: winuser.h:3138
#define CS_VREDRAW
Definition: winuser.h:653
int cbWndExtra
Definition: winuser.h:3132
#define CS_GLOBALCLASS
Definition: winuser.h:647
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define COLOR_BTNFACE
Definition: winuser.h:918
HCURSOR hCursor
Definition: winuser.h:3135
static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: updown.c:896
HBRUSH hbrBackground
Definition: winuser.h:3136
#define IDC_ARROW
Definition: winuser.h:682
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define UPDOWN_CLASSW
Definition: commctrl.h:2091

Referenced by DllMain().

◆ UPDOWN_ResetSubclass()

static void UPDOWN_ResetSubclass ( UPDOWN_INFO infoPtr)
static

Definition at line 608 of file updown.c.

609 {
611 }
BOOL WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef)
Definition: commctrl.c:1261
#define BUDDY_SUBCLASSID
Definition: updown.c:94
HWND Buddy
Definition: updown.c:53
static LRESULT CALLBACK UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uId, DWORD_PTR ref_data)
Definition: updown.c:574

Referenced by UPDOWN_SetBuddy(), and UpDownWindowProc().

◆ UPDOWN_SetBuddy()

static HWND UPDOWN_SetBuddy ( UPDOWN_INFO infoPtr,
HWND  bud 
)
static

Definition at line 623 of file updown.c.

624 {
625  RECT budRect; /* new coord for the buddy */
626  int x, width; /* new x position and width for the up-down */
627  WCHAR buddyClass[40];
628  HWND old_buddy;
629 
630  TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud);
631 
632  old_buddy = infoPtr->Buddy;
633 
634  UPDOWN_ResetSubclass (infoPtr);
635 
636  if (!IsWindow(bud)) bud = NULL;
637 
638  /* Store buddy window handle */
639  infoPtr->Buddy = bud;
640 
641  if(bud) {
642  /* Store buddy window class type */
643  infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN;
644  if (GetClassNameW(bud, buddyClass, ARRAY_SIZE(buddyClass))) {
645  if (lstrcmpiW(buddyClass, WC_EDITW) == 0)
646  infoPtr->BuddyType = BUDDY_TYPE_EDIT;
647  else if (lstrcmpiW(buddyClass, WC_LISTBOXW) == 0)
648  infoPtr->BuddyType = BUDDY_TYPE_LISTBOX;
649  }
650 
651  if (infoPtr->dwStyle & UDS_ARROWKEYS)
653  (DWORD_PTR)infoPtr->Self);
654 
655  /* Get the rect of the buddy relative to its parent */
656  GetWindowRect(infoPtr->Buddy, &budRect);
657  MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2);
658 
659  /* now do the positioning */
660  if (infoPtr->dwStyle & UDS_ALIGNLEFT) {
661  x = budRect.left;
662  budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP;
663  } else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) {
664  budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP;
665  x = budRect.right+DEFAULT_XSEP;
666  } else {
667  /* nothing to do */
668  return old_buddy;
669  }
670 
671  /* first adjust the buddy to accommodate the up/down */
672  SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
673  budRect.right - budRect.left, budRect.bottom - budRect.top,
675 
676  /* now position the up/down */
677  /* Since the UDS_ALIGN* flags were used, */
678  /* we will pick the position and size of the window. */
680 
681  /*
682  * If the updown has a buddy border, it has to overlap with the buddy
683  * to look as if it is integrated with the buddy control.
684  * We nudge the control or change its size to overlap.
685  */
686  if (UPDOWN_HasBuddyBorder(infoPtr)) {
687  if(infoPtr->dwStyle & UDS_ALIGNLEFT)
689  else
691  }
692 
693  SetWindowPos(infoPtr->Self, 0, x,
694  budRect.top - DEFAULT_ADDTOP, width,
695  budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT,
697  } else if (!(infoPtr->dwStyle & UDS_HORZ) && old_buddy != NULL) {
698  RECT rect;
699  GetWindowRect(infoPtr->Self, &rect);
700  MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Self), (POINT *)&rect, 2);
701  SetWindowPos(infoPtr->Self, 0, rect.left, rect.top, DEFAULT_WIDTH, rect.bottom - rect.top,
703  }
704 
705  return old_buddy;
706 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define WC_EDITW
Definition: commctrl.h:4658
#define UDS_ALIGNLEFT
Definition: commctrl.h:2106
#define DEFAULT_BUDDYBORDER
Definition: updown.c:69
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define DEFAULT_WIDTH
Definition: updown.c:65
LONG top
Definition: windef.h:292
#define DEFAULT_XSEP
Definition: updown.c:66
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
LONG right
Definition: windef.h:293
DWORD dwStyle
Definition: updown.c:45
& rect
Definition: startmenu.cpp:1413
#define BUDDY_TYPE_UNKNOWN
Definition: updown.c:83
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
#define BUDDY_TYPE_LISTBOX
Definition: updown.c:84
#define BUDDY_TYPE_EDIT
Definition: updown.c:85
#define UDS_ARROWKEYS
Definition: commctrl.h:2108
HWND Self
Definition: updown.c:43
smooth NULL
Definition: ftsmooth.c:416
static void UPDOWN_ResetSubclass(UPDOWN_INFO *infoPtr)
Definition: updown.c:608
BOOL WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef)
Definition: commctrl.c:1261
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define WC_LISTBOXW
Definition: commctrl.h:4682
#define BUDDY_SUBCLASSID
Definition: updown.c:94
#define SWP_FRAMECHANGED
Definition: winuser.h:1225
#define UDS_HORZ
Definition: commctrl.h:2109
#define DEFAULT_ADDBOT
Definition: updown.c:68
uint32_t DWORD_PTR
Definition: typedefs.h:63
HWND WINAPI GetParent(_In_ HWND)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define UDS_ALIGNRIGHT
Definition: commctrl.h:2105
static BOOL UPDOWN_HasBuddyBorder(const UPDOWN_INFO *infoPtr)
Definition: updown.c:161
#define HWND_DESKTOP
Definition: winuser.h:1195
HWND Buddy
Definition: updown.c:53
INT BuddyType
Definition: updown.c:54
static LRESULT CALLBACK UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uId, DWORD_PTR ref_data)
Definition: updown.c:574
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define DEFAULT_ADDTOP
Definition: updown.c:67

Referenced by UpDownWindowProc().

◆ UPDOWN_SetBuddyInt()

static BOOL UPDOWN_SetBuddyInt ( const UPDOWN_INFO infoPtr)
static

Definition at line 305 of file updown.c.

306 {
307  static const WCHAR fmt_hex[] = { '0', 'x', '%', '0', '4', 'X', 0 };
308  static const WCHAR fmt_dec_oct[] = { '%', 'd', '\0' };
309  const WCHAR *fmt;
310  WCHAR txt[20], txt_old[20] = { 0 };
311  int len;
312 
313  if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
314  return FALSE;
315 
316  TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal);
317 
318  /*if the buddy is a list window, we must set curr index */
319  if (UPDOWN_IsBuddyListbox(infoPtr)) {
320  return SendMessageW(infoPtr->Buddy, LB_SETCURSEL, infoPtr->CurVal, 0) != LB_ERR;
321  }
322 
323  /* Regular window, so set caption to the number */
324  fmt = (infoPtr->Base == 16) ? fmt_hex : fmt_dec_oct;
325  len = wsprintfW(txt, fmt, infoPtr->CurVal);
326 
327 
328  /* Do thousands separation if necessary */
329  if ((infoPtr->Base == 10) && !(infoPtr->dwStyle & UDS_NOTHOUSANDS) && (len > 3)) {
330  WCHAR tmp[ARRAY_SIZE(txt)], *src = tmp, *dst = txt;
332  int start = len % 3;
333 
334  memcpy(tmp, txt, sizeof(txt));
335  if (start == 0) start = 3;
336  dst += start;
337  src += start;
338  for (len=0; *src; len++) {
339  if (len % 3 == 0) *dst++ = sep;
340  *dst++ = *src++;
341  }
342  *dst = 0;
343  }
344 
345  /* if nothing changed exit earlier */
346  GetWindowTextW(infoPtr->Buddy, txt_old, ARRAY_SIZE(txt_old));
347  if (lstrcmpiW(txt_old, txt) == 0) return FALSE;
348 
349  return SetWindowTextW(infoPtr->Buddy, txt);
350 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define LB_SETCURSEL
Definition: winuser.h:2024
INT CurVal
Definition: updown.c:50
BOOL WINAPI IsWindow(_In_opt_ HWND)
const char * fmt
Definition: wsprintf.c:30
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
DWORD dwStyle
Definition: updown.c:45
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define LB_ERR
Definition: winuser.h:2386
#define UDS_NOTHOUSANDS
Definition: commctrl.h:2110
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1378
GLuint start
Definition: gl.h:1545
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GLenum GLenum dst
Definition: glext.h:6340
static WCHAR UPDOWN_GetThousandSep(void)
Definition: updown.c:243
HWND Buddy
Definition: updown.c:53
INT Base
Definition: updown.c:49
static BOOL UPDOWN_IsBuddyListbox(const UPDOWN_INFO *infoPtr)
Definition: updown.c:111
#define FLAG_BUDDYINT
Definition: updown.c:80
Definition: dsound.c:943
INT Flags
Definition: updown.c:55

Referenced by UPDOWN_DoAction(), UPDOWN_SetPos(), and UpDownWindowProc().

◆ UPDOWN_SetPos()

static int UPDOWN_SetPos ( UPDOWN_INFO infoPtr,
int  pos 
)
static

Definition at line 500 of file updown.c.

501 {
502  int ret = infoPtr->CurVal;
503 
504  if(!UPDOWN_InBounds(infoPtr, pos)) {
505  if((infoPtr->MinVal < infoPtr->MaxVal && pos < infoPtr->MinVal)
506  || (infoPtr->MinVal > infoPtr->MaxVal && pos > infoPtr->MinVal))
507  pos = infoPtr->MinVal;
508  else
509  pos = infoPtr->MaxVal;
510  }
511 
512  infoPtr->CurVal = pos;
513  UPDOWN_SetBuddyInt(infoPtr);
514 
515  if(!UPDOWN_InBounds(infoPtr, ret)) {
516  if((infoPtr->MinVal < infoPtr->MaxVal && ret < infoPtr->MinVal)
517  || (infoPtr->MinVal > infoPtr->MaxVal && ret > infoPtr->MinVal))
518  ret = infoPtr->MinVal;
519  else
520  ret = infoPtr->MaxVal;
521  }
522  return ret;
523 }
INT CurVal
Definition: updown.c:50
static BOOL UPDOWN_InBounds(const UPDOWN_INFO *infoPtr, int val)
Definition: updown.c:120
INT MaxVal
Definition: updown.c:52
static BOOL UPDOWN_SetBuddyInt(const UPDOWN_INFO *infoPtr)
Definition: updown.c:305
int ret
INT MinVal
Definition: updown.c:51

Referenced by UpDownWindowProc().

◆ UPDOWN_SetRange()

static LRESULT UPDOWN_SetRange ( UPDOWN_INFO infoPtr,
INT  Max,
INT  Min 
)
static

Definition at line 536 of file updown.c.

537 {
538  infoPtr->MaxVal = Max;
539  infoPtr->MinVal = Min;
540 
541  TRACE("UpDown Ctrl new range(%d to %d), hwnd=%p\n",
542  infoPtr->MinVal, infoPtr->MaxVal, infoPtr->Self);
543 
544  return 0;
545 }
INT MaxVal
Definition: updown.c:52
#define Max(a, b)
Definition: cdprocs.h:70
HWND Self
Definition: updown.c:43
#define TRACE(s)
Definition: solgame.cpp:4
#define Min(a, b)
Definition: cdprocs.h:66
INT MinVal
Definition: updown.c:51

Referenced by UpDownWindowProc().

◆ UPDOWN_Unregister()

void UPDOWN_Unregister ( void  )

Definition at line 1203 of file updown.c.

1204 {
1206 }
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
smooth NULL
Definition: ftsmooth.c:416
#define UPDOWN_CLASSW
Definition: commctrl.h:2091

Referenced by DllMain().

◆ UpDownWindowProc()

static LRESULT WINAPI UpDownWindowProc ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 896 of file updown.c.

897 {
898  UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
899  static const WCHAR themeClass[] = {'S','p','i','n',0};
900  HTHEME theme;
901 
902  TRACE("hwnd=%p msg=%04x wparam=%08lx lparam=%08lx\n", hwnd, message, wParam, lParam);
903 
904  if (!infoPtr && (message != WM_CREATE))
906 
907  switch(message)
908  {
909  case WM_CREATE:
910  {
912 
913  infoPtr = heap_alloc_zero(sizeof(*infoPtr));
914  SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
915 
916  /* initialize the info struct */
917  infoPtr->Self = hwnd;
918  infoPtr->Notify = pcs->hwndParent;
919  infoPtr->dwStyle = pcs->style;
920  infoPtr->AccelCount = 0;
921  infoPtr->AccelVect = 0;
922  infoPtr->AccelIndex = -1;
923  infoPtr->CurVal = 0;
924  infoPtr->MinVal = 100;
925  infoPtr->MaxVal = 0;
926  infoPtr->Base = 10; /* Default to base 10 */
927  infoPtr->Buddy = 0; /* No buddy window yet */
928  infoPtr->Flags = (infoPtr->dwStyle & UDS_SETBUDDYINT) ? FLAG_BUDDYINT : 0;
929 
931  if (!(infoPtr->dwStyle & UDS_HORZ))
932  SetWindowPos (hwnd, NULL, 0, 0, DEFAULT_WIDTH, pcs->cy,
934 
935  /* Do we pick the buddy win ourselves? */
936  if (infoPtr->dwStyle & UDS_AUTOBUDDY)
938 
940 
941  TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd);
942  }
943  break;
944 
945  case WM_DESTROY:
946  heap_free (infoPtr->AccelVect);
947  UPDOWN_ResetSubclass (infoPtr);
948  heap_free (infoPtr);
949  SetWindowLongPtrW (hwnd, 0, 0);
950  theme = GetWindowTheme (hwnd);
951  CloseThemeData (theme);
952  TRACE("UpDown Ctrl destruction, hwnd=%p\n", hwnd);
953  break;
954 
955  case WM_ENABLE:
956  if (wParam) {
957  infoPtr->dwStyle &= ~WS_DISABLED;
958  } else {
959  infoPtr->dwStyle |= WS_DISABLED;
960  UPDOWN_CancelMode (infoPtr);
961  }
962  InvalidateRect (infoPtr->Self, NULL, FALSE);
963  break;
964 
965  case WM_STYLECHANGED:
966  if (wParam == GWL_STYLE) {
967  infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew;
968  InvalidateRect (infoPtr->Self, NULL, FALSE);
969  }
970  break;
971 
972  case WM_THEMECHANGED:
973  theme = GetWindowTheme (hwnd);
974  CloseThemeData (theme);
977  break;
978 
979  case WM_TIMER:
980  /* is this the auto-press timer? */
981  if(wParam == TIMER_AUTOPRESS) {
983  infoPtr->Flags &= ~(FLAG_PRESSED | FLAG_ARROW);
984  InvalidateRect(infoPtr->Self, NULL, FALSE);
985  }
986 
987  /* if initial timer, kill it and start the repeat timer */
988  if(wParam == TIMER_AUTOREPEAT) {
989  INT delay;
990 
992  /* if no accel info given, used default timer */
993  if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0) {
994  infoPtr->AccelIndex = -1;
996  } else {
997  infoPtr->AccelIndex = 0; /* otherwise, use it */
998  delay = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
999  }
1001  }
1002 
1003  /* now, if the mouse is above us, do the thing...*/
1004  if(infoPtr->Flags & FLAG_MOUSEIN) {
1005  int temp;
1006 
1007  temp = infoPtr->AccelIndex == -1 ? 1 : infoPtr->AccelVect[infoPtr->AccelIndex].nInc;
1008  UPDOWN_DoAction(infoPtr, temp, infoPtr->Flags & FLAG_ARROW);
1009 
1010  if(infoPtr->AccelIndex != -1 && infoPtr->AccelIndex < infoPtr->AccelCount-1) {
1012  infoPtr->AccelIndex++; /* move to the next accel info */
1013  temp = infoPtr->AccelVect[infoPtr->AccelIndex].nSec * 1000 + 1;
1014  /* make sure we have at least 1ms intervals */
1015  SetTimer(hwnd, TIMER_ACCEL, temp, 0);
1016  }
1017  }
1018  break;
1019 
1020  case WM_CANCELMODE:
1021  return UPDOWN_CancelMode (infoPtr);
1022 
1023  case WM_LBUTTONUP:
1024  if (GetCapture() != infoPtr->Self) break;
1025 
1026  if ( (infoPtr->Flags & FLAG_MOUSEIN) &&
1027  (infoPtr->Flags & FLAG_ARROW) ) {
1028 
1029  SendMessageW( infoPtr->Notify,
1030  (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL,
1031  MAKELONG(SB_ENDSCROLL, infoPtr->CurVal),
1032  (LPARAM)hwnd);
1033  if (UPDOWN_IsBuddyEdit(infoPtr))
1034  SendMessageW(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1));
1035  }
1036  UPDOWN_CancelMode(infoPtr);
1037  break;
1038 
1039  case WM_LBUTTONDOWN:
1040  case WM_MOUSEMOVE:
1041  case WM_MOUSELEAVE:
1042  if(UPDOWN_IsEnabled(infoPtr))
1044  break;
1045 
1046  case WM_MOUSEWHEEL:
1047  UPDOWN_MouseWheel(infoPtr, wParam);
1048  break;
1049 
1050  case WM_KEYDOWN:
1051  if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr))
1052  return UPDOWN_KeyPressed(infoPtr, (int)wParam);
1053  break;
1054 
1055  case WM_PRINTCLIENT:
1056  case WM_PAINT:
1057  return UPDOWN_Paint (infoPtr, (HDC)wParam);
1058 
1059  case UDM_GETACCEL:
1060  if (wParam==0 && lParam==0) return infoPtr->AccelCount;
1061  if (wParam && lParam) {
1062  int temp = min(infoPtr->AccelCount, wParam);
1063  memcpy((void *)lParam, infoPtr->AccelVect, temp*sizeof(UDACCEL));
1064  return temp;
1065  }
1066  return 0;
1067 
1068  case UDM_SETACCEL:
1069  {
1070  TRACE("UDM_SETACCEL\n");
1071 
1072  if(infoPtr->AccelVect) {
1073  heap_free (infoPtr->AccelVect);
1074  infoPtr->AccelCount = 0;
1075  infoPtr->AccelVect = 0;
1076  }
1077  if(wParam==0) return TRUE;
1078  infoPtr->AccelVect = heap_alloc(wParam*sizeof(UDACCEL));
1079  if(!infoPtr->AccelVect) return FALSE;
1080  memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL));
1081  infoPtr->AccelCount = wParam;
1082 
1083  if (TRACE_ON(updown))
1084  {
1085  UINT i;
1086 
1087  for (i = 0; i < wParam; i++)
1088  TRACE("%u: nSec %u nInc %u\n", i,
1089  infoPtr->AccelVect[i].nSec, infoPtr->AccelVect[i].nInc);
1090  }
1091 
1092  return TRUE;
1093  }
1094  case UDM_GETBASE:
1095  return infoPtr->Base;
1096 
1097  case UDM_SETBASE:
1098  TRACE("UpDown Ctrl new base(%ld), hwnd=%p\n", wParam, hwnd);
1099  if (wParam==10 || wParam==16) {
1100  WPARAM old_base = infoPtr->Base;
1101  infoPtr->Base = wParam;
1102 
1103  if (old_base != infoPtr->Base)
1104  UPDOWN_SetBuddyInt(infoPtr);
1105 
1106  return old_base;
1107  }
1108  break;
1109 
1110  case UDM_GETBUDDY:
1111  return (LRESULT)infoPtr->Buddy;
1112 
1113  case UDM_SETBUDDY:
1114  return (LRESULT)UPDOWN_SetBuddy (infoPtr, (HWND)wParam);
1115 
1116  case UDM_GETPOS:
1117  {
1118  BOOL err;
1119  int pos;
1120 
1121  pos = UPDOWN_GetPos(infoPtr, &err);
1122  return MAKELONG(pos, err);
1123  }
1124  case UDM_SETPOS:
1125  {
1126  return UPDOWN_SetPos(infoPtr, (short)LOWORD(lParam));
1127  }
1128  case UDM_GETRANGE:
1129  return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal);
1130 
1131  case UDM_SETRANGE:
1132  /* we must have:
1133  UD_MINVAL <= Max <= UD_MAXVAL
1134  UD_MINVAL <= Min <= UD_MAXVAL
1135  |Max-Min| <= UD_MAXVAL */
1136  UPDOWN_SetRange(infoPtr, (short)lParam, (short)HIWORD(lParam));
1137  break;
1138 
1139  case UDM_GETRANGE32:
1140  if (wParam) *(LPINT)wParam = infoPtr->MinVal;
1141  if (lParam) *(LPINT)lParam = infoPtr->MaxVal;
1142  break;
1143 
1144  case UDM_SETRANGE32:
1145  UPDOWN_SetRange(infoPtr, (INT)lParam, (INT)wParam);
1146  break;
1147 
1148  case UDM_GETPOS32:
1149  {
1150  return UPDOWN_GetPos(infoPtr, (BOOL*)lParam);
1151  }
1152  case UDM_SETPOS32:
1153  {
1154  return UPDOWN_SetPos(infoPtr, (int)lParam);
1155  }
1156  case UDM_GETUNICODEFORMAT:
1157  /* we lie a bit here, we're always using Unicode internally */
1158  return infoPtr->UnicodeFormat;
1159 
1160  case UDM_SETUNICODEFORMAT:
1161  {
1162  /* do we really need to honour this flag? */
1163  int temp = infoPtr->UnicodeFormat;
1164  infoPtr->UnicodeFormat = (BOOL)wParam;
1165  return temp;
1166  }
1167  default:
1169  ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam);
1170  return DefWindowProcW (hwnd, message, wParam, lParam);
1171  }
1172 
1173  return 0;
1174 }
#define WS_DISABLED
Definition: pedump.c:621
static LRESULT UPDOWN_Paint(const UPDOWN_INFO *infoPtr, HDC hdc)
Definition: updown.c:448
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
static int UPDOWN_GetPos(UPDOWN_INFO *infoPtr, BOOL *err)
Definition: updown.c:481
#define TRUE
Definition: types.h:120
#define UDM_GETPOS
Definition: commctrl.h:2116
#define UDM_GETPOS32
Definition: commctrl.h:2128
#define TIMER_AUTOREPEAT
Definition: updown.c:87
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
INT CurVal
Definition: updown.c:50
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define DEFAULT_WIDTH
Definition: updown.c:65
INT MaxVal
Definition: updown.c:52
static HDC
Definition: imagelist.c:92
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define UDM_SETACCEL
Definition: commctrl.h:2119
UINT_PTR WPARAM
Definition: windef.h:207
INT AccelIndex
Definition: updown.c:48
#define SWP_NOZORDER
Definition: winuser.h:1232
#define UDM_GETRANGE32
Definition: commctrl.h:2124
static const WCHAR themeClass[]
Definition: header.c:115
int32_t INT
Definition: typedefs.h:56
DWORD dwStyle
Definition: updown.c:45
WPARAM wParam
Definition: combotst.c:138
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define WM_ENABLE
Definition: winuser.h:1597
#define TIMER_AUTOPRESS
Definition: updown.c:89
#define WM_PRINTCLIENT
Definition: richedit.h:70
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define UPDOWN_GetInfoPtr(hwnd)
Definition: updown.c:91
static BOOL UPDOWN_IsEnabled(const UPDOWN_INFO *infoPtr)
Definition: updown.c:759
static int UPDOWN_SetPos(UPDOWN_INFO *infoPtr, int pos)
Definition: updown.c:500
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define UDM_GETBASE
Definition: commctrl.h:2122
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FLAG_PRESSED
Definition: updown.c:79
static BOOL UPDOWN_IsBuddyEdit(const UPDOWN_INFO *infoPtr)
Definition: updown.c:102
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
short SHORT
Definition: pedump.c:59
HWND WINAPI GetCapture(void)
Definition: message.c:2879
#define WM_MOUSELEAVE
Definition: commctrl.h:4946
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define UDS_ARROWKEYS
Definition: commctrl.h:2108
HWND Self
Definition: updown.c:43
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
LONG_PTR LPARAM
Definition: windef.h:208
#define UDM_SETRANGE
Definition: commctrl.h:2113
static void UPDOWN_ResetSubclass(UPDOWN_INFO *infoPtr)
Definition: updown.c:608
#define UDM_SETRANGE32
Definition: commctrl.h:2123
#define SB_ENDSCROLL
Definition: winuser.h:574
UINT AccelCount
Definition: updown.c:46
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1591
#define REPEAT_DELAY
Definition: updown.c:63
struct tagSTYLESTRUCT * LPSTYLESTRUCT
#define TRACE(s)
Definition: solgame.cpp:4
#define FLAG_MOUSEIN
Definition: updown.c:78
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT nSec
Definition: commctrl.h:2096
#define WM_TIMER
Definition: winuser.h:1718
#define UDM_SETPOS32
Definition: commctrl.h:2127
#define EM_SETSEL
Definition: winuser.h:1979
static BOOL UPDOWN_SetBuddyInt(const UPDOWN_INFO *infoPtr)
Definition: updown.c:305
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
#define WM_PAINT
Definition: winuser.h:1602
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
void delay(unsigned msec)
Definition: i386rtl.c:32
BOOL UnicodeFormat
Definition: updown.c:56
static LRESULT UPDOWN_MouseWheel(UPDOWN_INFO *infoPtr, WPARAM wParam)
Definition: updown.c:552
#define WM_CANCELMODE
Definition: winuser.h:1617
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
UINT nInc
Definition: commctrl.h:2097
static LRESULT UPDOWN_SetRange(UPDOWN_INFO *infoPtr, INT Max, INT Min)
Definition: updown.c:536
#define UDS_HORZ
Definition: commctrl.h:2109
#define WM_APP
Definition: eventvwr.h:70
#define err(...)
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define WM_USER
Definition: winuser.h:1856
#define ERR(fmt,...)
Definition: debug.h:109
#define GWL_STYLE
Definition: winuser.h:846
#define UDS_AUTOBUDDY
Definition: commctrl.h:2107
#define FLAG_ARROW
Definition: updown.c:81
#define UDM_SETBUDDY
Definition: commctrl.h:2117
#define UDM_GETACCEL
Definition: commctrl.h:2120
#define WS_BORDER
Definition: pedump.c:625
static BOOL(WINAPI *pSetWindowSubclass)(HWND
static calc_node_t temp
Definition: rpn_ieee.c:38
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define UDM_SETPOS
Definition: commctrl.h:2115
#define min(a, b)
Definition: monoChain.cc:55
#define UDM_GETRANGE
Definition: commctrl.h:2114
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define WM_HSCROLL
Definition: winuser.h:1719
#define UDM_GETBUDDY
Definition: commctrl.h:2118
INT MinVal
Definition: updown.c:51
HWND Buddy
Definition: updown.c:53
INT Base
Definition: updown.c:49
static HWND UPDOWN_SetBuddy(UPDOWN_INFO *infoPtr, HWND bud)
Definition: updown.c:623
static BOOL UPDOWN_CancelMode(UPDOWN_INFO *infoPtr)
Definition: updown.c:776
#define WM_CREATE
Definition: winuser.h:1590
UDACCEL * AccelVect
Definition: updown.c:47
#define UDS_SETBUDDYINT
Definition: commctrl.h:2104
#define HIWORD(l)
Definition: typedefs.h:246
#define FLAG_BUDDYINT
Definition: updown.c:80
BOOL COMCTL32_IsReflectedMessage(UINT uMsg) DECLSPEC_HIDDEN
Definition: commctrl.c:1748
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
HWND Notify
Definition: updown.c:44
#define SetWindowLongPtrW
Definition: winuser.h:5215
LONG_PTR LRESULT
Definition: windef.h:209
static INT
Definition: updown.c:66
#define TRACE_ON(x)
Definition: compat.h:65
#define UDM_GETUNICODEFORMAT
Definition: commctrl.h:2126
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define GW_HWNDPREV
Definition: winuser.h:757
#define UDM_SETBASE
Definition: commctrl.h:2121
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
#define WM_VSCROLL
Definition: winuser.h:1720
#define TIMER_ACCEL
Definition: updown.c:88
static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key)
Definition: updown.c:463
static void UPDOWN_DoAction(UPDOWN_INFO *infoPtr, int delta, int action)
Definition: updown.c:718
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static void UPDOWN_HandleMouseEvent(UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y)
Definition: updown.c:806
INT Flags
Definition: updown.c:55
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234
int * LPINT
Definition: windef.h:178
#define UDM_SETUNICODEFORMAT
Definition: commctrl.h:2125

Referenced by UPDOWN_Register().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( updown  )