29 #include "../../idlib/precompiled.h"
32 #include "../../sys/win32/win_local.h"
35 #include "../../sys/win32/rc/guied_resource.h"
37 static HHOOK gAlphaHook =
NULL;
38 static HWND gAlphaDlg =
NULL;
47 static void AlphaSlider_DrawArrow (
HDC hDC, RECT* pRect, COLORREF
color )
51 ptsArrow[0].
x = pRect->left;
52 ptsArrow[0].
y = pRect->bottom;
53 ptsArrow[1].
x = (pRect->left + pRect->right)/2;
54 ptsArrow[1].
y = pRect->top;
55 ptsArrow[2].
x = pRect->right;
56 ptsArrow[2].
y = pRect->bottom;
58 HBRUSH arrowBrush = CreateSolidBrush ( color );
59 HPEN arrowPen = CreatePen ( PS_SOLID, 1, color );
61 HGDIOBJ oldBrush = SelectObject ( hDC, arrowBrush );
62 HGDIOBJ oldPen = SelectObject ( hDC, arrowPen );
64 SetPolyFillMode(hDC, WINDING);
65 Polygon(hDC, ptsArrow, 3);
67 SelectObject ( hDC, oldBrush );
68 SelectObject ( hDC, oldPen );
70 DeleteObject ( arrowBrush );
71 DeleteObject ( arrowPen );
90 GetClientRect ( hwnd, &rClient );
91 v = (
float)((
short)LOWORD(lParam)-5) / (
float)(rClient.right - rClient.left - 10);
93 if ( v > 1.0
f ) v = 1.0f;
94 SetWindowLong ( hwnd, GWL_USERDATA, MAKELONG(0x8000,(
unsigned short)(255.0
f * v)) );
103 if ( LOWORD(GetWindowLong ( hwnd, GWL_USERDATA ) ) & 0x8000 )
108 GetClientRect ( hwnd, &rClient );
109 v = (
float)((
short)LOWORD(lParam)-5) / (
float)(rClient.right - rClient.left - 10);
111 if ( v > 1.0
f ) v = 1.0f;
112 SetWindowLong ( hwnd, GWL_USERDATA, MAKELONG(0x8000,(
unsigned short)(255.0
f * v)) );
118 if ( LOWORD(GetWindowLong ( hwnd, GWL_USERDATA ) ) & 0x8000 )
123 GetClientRect ( hwnd, &rClient );
124 v = (
float)((
short)LOWORD(lParam)-5) / (
float)(rClient.right - rClient.left - 10);
126 if ( v > 1.0
f ) v = 1.0f;
127 SetWindowLong ( hwnd, GWL_USERDATA, MAKELONG(0x8000,(
unsigned short)(255.0
f * v)) );
130 SendMessage (
GetParent ( hwnd ), WM_COMMAND, MAKELONG(GetWindowLong (hwnd,GWL_ID),0), 0 );
137 HDC hDC = BeginPaint ( hwnd, &ps );
141 GetClientRect ( hwnd, &rClient );
144 CopyRect ( &rDraw, &rClient );
152 float step = (
float)(rDraw.right-rDraw.left) / (
float)parts;
153 CopyRect ( &rColor, &rDraw );
154 for (
int i = 0;
i < parts;
i ++ )
158 rColor.left = rDraw.left +
i * step;
159 rColor.right = rColor.left + step + 1;
161 HBRUSH brush = CreateSolidBrush ( RGB((
int)color,(
int)color,(
int)color) );
162 FillRect ( hDC, &rColor, brush );
163 DeleteObject ( brush );
167 FrameRect (hDC, &rDraw, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
170 rClient.top = rDraw.bottom;
171 FillRect ( hDC, &rClient, GetSysColorBrush ( COLOR_3DFACE ) );
175 short s = HIWORD(GetWindowLong ( hwnd, GWL_USERDATA ));
176 float thumb = (
float)(
short)
s;
178 thumb *= (
float)(rDraw.right-rDraw.left);
179 rThumb.left = rDraw.left - 5 + thumb;
180 rThumb.right = rThumb.left + 10;
181 rThumb.top = rDraw.bottom + 1;
182 rThumb.bottom = rThumb.top + 5;
183 AlphaSlider_DrawArrow ( hDC, &rThumb, RGB(0,0,0) );
185 EndPaint ( hwnd, &ps );
190 return DefWindowProc ( hwnd, msg, wParam, lParam );
202 LPMSG lpMsg = (LPMSG) lParam;
204 if ( nCode >= 0 && PM_REMOVE == wParam )
207 if ( (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST) )
209 if ( IsDialogMessage( gAlphaDlg, lpMsg) )
215 lpMsg->message = WM_NULL;
222 return CallNextHookEx(gAlphaHook, nCode, wParam, lParam);
245 SetWindowLong ( hwnd, GWL_USERDATA, lParam );
252 SetWindowText ( GetDlgItem ( hwnd,
IDC_GUIED_ALPHA ),
va(
"%.3f", ((
float)color / 255.0
f) ) );
257 UnhookWindowsHookEx( gAlphaHook );
263 if ( !LOWORD(wParam) )
265 EndDialog ( hwnd, 0 );
270 switch ( LOWORD(wParam) )
279 value = atof ( temp );
285 else if ( value > 1.0
f )
300 EndDialog ( hwnd, 0 );
305 EndDialog ( hwnd, 0 );
328 memset ( &wndClass, 0,
sizeof(wndClass) );
329 wndClass.cbSize =
sizeof(WNDCLASSEX);
330 wndClass.lpszClassName =
"GUIED_ALPHASLIDER";
333 RegisterClassEx ( &wndClass );
335 GetWindowRect ( button, &rWindow );
338 SetWindowPos ( dlg,
NULL, rWindow.left, rWindow.bottom + 1, 0, 0, SWP_NOSIZE|SWP_NOZORDER );
339 ShowWindow ( dlg, SW_SHOW );
340 UpdateWindow ( dlg );
GLsizei const GLfloat * value
CONST PIXELFORMATDESCRIPTOR UINT
#define IDC_GUIED_ALPHASLIDER
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
MFnDagNode * GetParent(MFnDagNode *joint)
void NumberEdit_Attach(HWND hWnd)
char * va(const char *fmt,...)