Release 980329
[wine/multimedia.git] / controls / commctrl.c
blobf9400fd5add08b5b63837010a7d9324c09e79356
1 /*
2 * Common controls functions
4 * Copyright 1997 Dimitrie O. Paun
6 */
8 #include "win.h"
9 #include "heap.h"
10 #include "commctrl.h"
11 #include "progress.h"
12 #include "status.h"
13 #include "updown.h"
15 /* Win32 common controls */
17 static WNDCLASS32A WIDGETS_CommonControls32[] =
19 { CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW, StatusWindowProc, 0,
20 sizeof(STATUSWINDOWINFO), 0, 0, 0, 0, 0, STATUSCLASSNAME32A },
21 { CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW, UpDownWindowProc, 0,
22 sizeof(UPDOWN_INFO), 0, 0, 0, 0, 0, UPDOWN_CLASS32A },
23 { CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW, ProgressWindowProc, 0,
24 sizeof(PROGRESS_INFO), 0, 0, 0, 0, 0, PROGRESS_CLASS32A }
27 #define NB_COMMON_CONTROLS32 \
28 (sizeof(WIDGETS_CommonControls32)/sizeof(WIDGETS_CommonControls32[0]))
31 /***********************************************************************
32 * DrawStatusText32A (COMCTL32.5)
34 void WINAPI DrawStatusText32A( HDC32 hdc, LPRECT32 lprc, LPCSTR text,
35 UINT32 style )
37 RECT32 r = *lprc;
38 UINT32 border = BDR_SUNKENOUTER;
40 DrawEdge32(hdc, &r, BDR_RAISEDINNER, BF_RECT|BF_ADJUST|BF_FLAT);
42 if(style==SBT_POPOUT)
43 border = BDR_RAISEDOUTER;
44 else if(style==SBT_NOBORDERS)
45 border = 0;
47 DrawEdge32(hdc, &r, border, BF_RECT|BF_ADJUST|BF_MIDDLE);
49 /* now draw text */
50 if (text) {
51 int oldbkmode = SetBkMode32(hdc, TRANSPARENT);
52 r.left += 3;
53 DrawText32A(hdc, text, lstrlen32A(text),
54 &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
55 if (oldbkmode != TRANSPARENT)
56 SetBkMode32(hdc, oldbkmode);
61 /***********************************************************************
62 * DrawStatusText32W (COMCTL32.24)
64 void WINAPI DrawStatusText32W( HDC32 hdc, LPRECT32 lprc, LPCWSTR text,
65 UINT32 style )
67 LPSTR p = HEAP_strdupWtoA( GetProcessHeap(), 0, text );
68 DrawStatusText32A(hdc, lprc, p, style);
69 HeapFree( GetProcessHeap(), 0, p );
72 /***********************************************************************
73 * DrawStatusText16 (COMCTL32.23)
75 void WINAPI DrawStatusText16( HDC16 hdc, LPRECT16 lprc, LPCSTR text,
76 UINT16 style )
78 if(!lprc)
79 DrawStatusText32A((HDC32)hdc, 0, text, (UINT32)style);
80 else{
81 RECT32 rect32;
82 CONV_RECT16TO32( lprc, &rect32 );
83 DrawStatusText32A((HDC32)hdc, &rect32, text, (UINT32)style);
87 /***********************************************************************
88 * CreateStatusWindow32A (COMCTL32.6)
90 HWND32 WINAPI CreateStatusWindow32A( INT32 style, LPCSTR text, HWND32 parent,
91 UINT32 wid )
93 return CreateWindow32A(STATUSCLASSNAME32A, text, style,
94 CW_USEDEFAULT32, CW_USEDEFAULT32,
95 CW_USEDEFAULT32, CW_USEDEFAULT32,
96 parent, wid, 0, 0);
99 /***********************************************************************
100 * CreateStatusWindow16 (COMCTL32.18)
102 HWND16 WINAPI CreateStatusWindow16( INT16 style, LPCSTR text, HWND16 parent,
103 UINT16 wid )
105 return CreateWindow16(STATUSCLASSNAME16, text, style,
106 CW_USEDEFAULT16, CW_USEDEFAULT16,
107 CW_USEDEFAULT16, CW_USEDEFAULT16,
108 parent, wid, 0, 0);
111 /***********************************************************************
112 * CreateStatusWindow32W (COMCTL32.19)
114 HWND32 WINAPI CreateStatusWindow32W( INT32 style, LPCWSTR text, HWND32 parent,
115 UINT32 wid )
117 return CreateWindow32W(STATUSCLASSNAME32W, text, style,
118 CW_USEDEFAULT32, CW_USEDEFAULT32,
119 CW_USEDEFAULT32, CW_USEDEFAULT32,
120 parent, wid, 0, 0);
123 /***********************************************************************
124 * CreateUpDownControl (COMCTL32.16)
126 HWND32 WINAPI CreateUpDownControl( DWORD style, INT32 x, INT32 y,
127 INT32 cx, INT32 cy, HWND32 parent,
128 INT32 id, HINSTANCE32 inst, HWND32 buddy,
129 INT32 maxVal, INT32 minVal, INT32 curVal )
131 HWND32 hUD = CreateWindow32A(UPDOWN_CLASS32A, 0, style, x, y, cx, cy,
132 parent, id, inst, 0);
133 if(hUD){
134 SendMessage32A(hUD, UDM_SETBUDDY, buddy, 0);
135 SendMessage32A(hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
136 SendMessage32A(hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
139 return hUD;
143 /***********************************************************************
144 * InitCommonControls (COMCTL32.17)
146 void WINAPI InitCommonControls(void)
148 int i;
149 char name[30];
150 const char *old_name;
151 WNDCLASS32A *class32 = WIDGETS_CommonControls32;
153 for (i = 0; i < NB_COMMON_CONTROLS32; i++, class32++)
155 /* Just to make sure the string is > 0x10000 */
156 old_name = class32->lpszClassName;
157 strcpy( name, (char *)class32->lpszClassName );
158 class32->lpszClassName = name;
159 class32->hCursor = LoadCursor32A( 0, (LPCSTR)IDC_ARROW );
160 RegisterClass32A( class32 );
161 class32->lpszClassName = old_name;