1999-02-28 21:05:11 +01:00
|
|
|
/*
|
2000-04-24 19:35:11 +02:00
|
|
|
* COMMDLG - Color Dialog
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
|
2000-07-23 16:21:38 +02:00
|
|
|
/* BUGS : still seems to not refresh correctly
|
|
|
|
sometimes, especially when 2 instances of the
|
|
|
|
dialog are loaded at the same time */
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1999-02-28 21:05:11 +01:00
|
|
|
#include <string.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "wine/winuser16.h"
|
|
|
|
#include "commdlg.h"
|
|
|
|
#include "dlgs.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-13 18:07:56 +01:00
|
|
|
#include "cderr.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-04-25 20:31:35 +02:00
|
|
|
#include "cdlg.h"
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
static LRESULT WINAPI ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam );
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
#define CONV_LPARAMTOPOINT(lp,p) do { (p)->x = SLOWORD(lp); (p)->y = SHIWORD(lp); } while(0)
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
static const COLORREF predefcolors[6][8]=
|
|
|
|
{
|
|
|
|
{ 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
|
|
|
|
0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
|
|
|
|
{ 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
|
|
|
|
0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
|
|
|
|
|
|
|
|
{ 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
|
|
|
|
0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
|
|
|
|
{ 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
|
|
|
|
0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
|
|
|
|
|
|
|
|
{ 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
|
|
|
|
0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
|
|
|
|
{ 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
|
|
|
|
0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CCPRIVATE
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
LPCHOOSECOLORW lpcc; /* points to public known data structure */
|
|
|
|
LPCHOOSECOLOR16 lpcc16; /* save the 16 bits pointer */
|
1999-02-28 21:05:11 +01:00
|
|
|
int nextuserdef; /* next free place in user defined color array */
|
2000-04-24 19:35:11 +02:00
|
|
|
HDC hdcMem; /* color graph used for BitBlt() */
|
2002-06-01 01:06:46 +02:00
|
|
|
HBITMAP hbmMem; /* color graph bitmap */
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT fullsize; /* original dialog window size */
|
|
|
|
UINT msetrgb; /* # of SETRGBSTRING message (today not used) */
|
|
|
|
RECT old3angle; /* last position of l-marker */
|
|
|
|
RECT oldcross; /* last position of color/satuation marker */
|
2000-08-26 22:31:48 +02:00
|
|
|
BOOL updating; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */
|
1999-02-28 21:05:11 +01:00
|
|
|
int h;
|
|
|
|
int s;
|
|
|
|
int l; /* for temporary storing of hue,sat,lum */
|
2000-04-24 19:35:11 +02:00
|
|
|
int capturedGraph; /* control mouse captured */
|
2000-07-23 16:21:38 +02:00
|
|
|
RECT focusRect; /* rectangle last focused item */
|
|
|
|
HWND hwndFocus; /* handle last focused item */
|
1999-02-28 21:05:11 +01:00
|
|
|
};
|
|
|
|
|
2000-07-23 16:21:38 +02:00
|
|
|
#define LCCPRIV struct CCPRIVATE *
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_HSLtoRGB [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static int CC_HSLtoRGB(char c, int hue, int sat, int lum)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int res = 0, maxrgb;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/* hue */
|
|
|
|
switch(c)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
case 'R': if (hue > 80) hue -= 80; else hue += 160; break;
|
|
|
|
case 'G': if (hue > 160) hue -= 160; else hue += 80; break;
|
|
|
|
case 'B': break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* l below 120 */
|
2000-04-24 19:35:11 +02:00
|
|
|
maxrgb = (256 * min(120,lum)) / 120; /* 0 .. 256 */
|
|
|
|
if (hue < 80)
|
|
|
|
res = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (hue < 120)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
res = (hue - 80) * maxrgb; /* 0...10240 */
|
|
|
|
res /= 40; /* 0...256 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (hue < 200)
|
|
|
|
res = maxrgb;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
res= (240 - hue) * maxrgb;
|
|
|
|
res /= 40;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
res = res - maxrgb / 2; /* -128...128 */
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/* saturation */
|
2000-04-24 19:35:11 +02:00
|
|
|
res = maxrgb / 2 + (sat * res) / 240; /* 0..256 */
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/* lum above 120 */
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lum > 120 && res < 256)
|
|
|
|
res += ((lum - 120) * (256 - res)) / 120;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
return min(res, 255);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_RGBtoHSL [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static int CC_RGBtoHSL(char c, int r, int g, int b)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
WORD maxi, mini, mmsum, mmdif, result = 0;
|
|
|
|
int iresult = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
maxi = max(r, b);
|
|
|
|
maxi = max(maxi, g);
|
|
|
|
mini = min(r, b);
|
|
|
|
mini = min(mini, g);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
mmsum = maxi + mini;
|
|
|
|
mmdif = maxi - mini;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
switch(c)
|
|
|
|
{
|
|
|
|
/* lum */
|
2000-04-24 19:35:11 +02:00
|
|
|
case 'L': mmsum *= 120; /* 0...61200=(255+255)*120 */
|
|
|
|
result = mmsum / 255; /* 0...240 */
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
/* saturation */
|
2000-04-24 19:35:11 +02:00
|
|
|
case 'S': if (!mmsum)
|
|
|
|
result = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (!mini || maxi == 255)
|
|
|
|
result = 240;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
result = mmdif * 240; /* 0...61200=255*240 */
|
|
|
|
result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* hue */
|
2000-04-24 19:35:11 +02:00
|
|
|
case 'H': if (!mmdif)
|
|
|
|
result = 160;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
if (maxi == r)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
iresult = 40 * (g - b); /* -10200 ... 10200 */
|
|
|
|
iresult /= (int) mmdif; /* -40 .. 40 */
|
|
|
|
if (iresult < 0)
|
|
|
|
iresult += 240; /* 0..40 and 200..240 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (maxi == g)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
iresult = 40 * (b - r);
|
|
|
|
iresult /= (int) mmdif;
|
|
|
|
iresult += 80; /* 40 .. 120 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (maxi == b)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
iresult = 40 * (r - g);
|
|
|
|
iresult /= (int) mmdif;
|
|
|
|
iresult += 160; /* 120 .. 200 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
result = iresult;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result; /* is this integer arithmetic precise enough ? */
|
|
|
|
}
|
|
|
|
|
2000-07-23 16:21:38 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_DrawCurrentFocusRect [internal]
|
|
|
|
*/
|
|
|
|
void CC_DrawCurrentFocusRect( LCCPRIV lpp )
|
|
|
|
{
|
|
|
|
if (lpp->hwndFocus)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(lpp->hwndFocus);
|
|
|
|
DrawFocusRect(hdc, &lpp->focusRect);
|
|
|
|
ReleaseDC(lpp->hwndFocus, hdc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_DrawFocusRect [internal]
|
|
|
|
*/
|
|
|
|
void CC_DrawFocusRect( LCCPRIV lpp, HWND hwnd, int x, int y, int rows, int cols)
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
int dx, dy;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
CC_DrawCurrentFocusRect(lpp); /* remove current focus rect */
|
|
|
|
/* calculate new rect */
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
dx = (rect.right - rect.left) / cols;
|
|
|
|
dy = (rect.bottom - rect.top) / rows;
|
|
|
|
rect.left += (x * dx) - 2;
|
|
|
|
rect.top += (y * dy) - 2;
|
|
|
|
rect.right = rect.left + dx;
|
|
|
|
rect.bottom = rect.top + dy;
|
|
|
|
/* draw it */
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
DrawFocusRect(hdc, &rect);
|
|
|
|
CopyRect(&lpp->focusRect, &rect);
|
|
|
|
lpp->hwndFocus = hwnd;
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
#define DISTANCE 4
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckPredefColorArray [internal]
|
2000-04-24 19:35:11 +02:00
|
|
|
* returns 1 if one of the predefined colors is clicked
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-07-23 16:21:38 +02:00
|
|
|
static int CC_MouseCheckPredefColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
|
|
|
|
LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
|
|
|
int dx, dy, x, y;
|
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2000-04-24 19:35:11 +02:00
|
|
|
ClientToScreen(hDlg, &point);
|
|
|
|
hwnd = GetDlgItem(hDlg, dlgitem);
|
|
|
|
GetWindowRect(hwnd, &rect);
|
|
|
|
if (PtInRect(&rect, point))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
dx = (rect.right - rect.left) / cols;
|
|
|
|
dy = (rect.bottom - rect.top) / rows;
|
|
|
|
ScreenToClient(hwnd, &point);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (point.x % dx < ( dx - DISTANCE) && point.y % dy < ( dy - DISTANCE))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
x = point.x / dx;
|
|
|
|
y = point.y / dy;
|
2000-07-23 16:21:38 +02:00
|
|
|
lpp->lpcc->rgbResult = predefcolors[y][x];
|
|
|
|
CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
|
1999-02-28 21:05:11 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckUserColorArray [internal]
|
2000-07-23 16:21:38 +02:00
|
|
|
* return 1 if the user clicked a color
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-07-23 16:21:38 +02:00
|
|
|
static int CC_MouseCheckUserColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
|
|
|
|
LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
|
|
|
int dx, dy, x, y;
|
2000-07-23 16:21:38 +02:00
|
|
|
COLORREF *crarr = lpp->lpcc->lpCustColors;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2000-04-24 19:35:11 +02:00
|
|
|
ClientToScreen(hDlg, &point);
|
2000-07-23 16:21:38 +02:00
|
|
|
hwnd = GetDlgItem(hDlg, dlgitem);
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowRect(hwnd, &rect);
|
|
|
|
if (PtInRect(&rect, point))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
dx = (rect.right - rect.left) / cols;
|
|
|
|
dy = (rect.bottom - rect.top) / rows;
|
|
|
|
ScreenToClient(hwnd, &point);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (point.x % dx < (dx - DISTANCE) && point.y % dy < (dy - DISTANCE))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
x = point.x / dx;
|
|
|
|
y = point.y / dy;
|
2000-07-23 16:21:38 +02:00
|
|
|
lpp->lpcc->rgbResult = crarr[x + (cols * y) ];
|
|
|
|
CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
|
1999-02-28 21:05:11 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAXVERT 240
|
|
|
|
#define MAXHORI 239
|
|
|
|
|
|
|
|
/* 240 ^...... ^^ 240
|
|
|
|
| . ||
|
|
|
|
SAT | . || LUM
|
|
|
|
| . ||
|
|
|
|
+-----> 239 ----
|
|
|
|
HUE
|
|
|
|
*/
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckColorGraph [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static int CC_MouseCheckColorGraph( HWND hDlg, int dlgitem, int *hori, int *vert, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
2000-04-24 19:35:11 +02:00
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
1999-02-28 21:05:11 +01:00
|
|
|
long x,y;
|
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2000-04-24 19:35:11 +02:00
|
|
|
ClientToScreen(hDlg, &point);
|
|
|
|
hwnd = GetDlgItem( hDlg, dlgitem );
|
|
|
|
GetWindowRect(hwnd, &rect);
|
|
|
|
if (PtInRect(&rect, point))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ScreenToClient(hwnd, &point);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
x = (long) point.x * MAXHORI;
|
|
|
|
x /= rect.right;
|
|
|
|
y = (long) (rect.bottom - point.y) * MAXVERT;
|
|
|
|
y /= rect.bottom;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (hori)
|
2000-04-24 19:35:11 +02:00
|
|
|
*hori = x;
|
1999-02-28 21:05:11 +01:00
|
|
|
if (vert)
|
2000-04-24 19:35:11 +02:00
|
|
|
*vert = y;
|
1999-02-28 21:05:11 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckResultWindow [internal]
|
2000-04-24 19:35:11 +02:00
|
|
|
* test if double click one of the result colors
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static int CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2000-04-24 19:35:11 +02:00
|
|
|
ClientToScreen(hDlg, &point);
|
|
|
|
hwnd = GetDlgItem(hDlg, 0x2c5);
|
|
|
|
GetWindowRect(hwnd, &rect);
|
|
|
|
if (PtInRect(&rect, point))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
PostMessageA(hDlg, WM_COMMAND, 0x2c9, 0);
|
1999-02-28 21:05:11 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_CheckDigitsInEdit [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static int CC_CheckDigitsInEdit( HWND hwnd, int maxval )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int i, k, m, result, value;
|
1999-02-28 21:05:11 +01:00
|
|
|
long editpos;
|
|
|
|
char buffer[30];
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowTextA(hwnd, buffer, sizeof(buffer));
|
|
|
|
m = strlen(buffer);
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
for (i = 0 ; i < m ; i++)
|
|
|
|
if (buffer[i] < '0' || buffer[i] > '9')
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
for (k = i + 1; k <= m; k++) /* delete bad character */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
buffer[i] = buffer[k];
|
1999-02-28 21:05:11 +01:00
|
|
|
m--;
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
buffer[m] = 0;
|
|
|
|
result = 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
value = atoi(buffer);
|
|
|
|
if (value > maxval) /* build a new string */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
sprintf(buffer, "%d", maxval);
|
|
|
|
result = 2;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (result)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
editpos = SendMessageA(hwnd, EM_GETSEL, 0, 0);
|
|
|
|
SetWindowTextA(hwnd, buffer );
|
|
|
|
SendMessageA(hwnd, EM_SETSEL, 0, editpos);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintSelectedColor [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_PaintSelectedColor( HWND hDlg, COLORREF cr )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect;
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hdc;
|
|
|
|
HBRUSH hBrush;
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd = GetDlgItem(hDlg, 0x2c5);
|
|
|
|
if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &rect) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
hBrush = CreateSolidBrush(cr);
|
|
|
|
if (hBrush)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hBrush = SelectObject(hdc, hBrush) ;
|
|
|
|
Rectangle(hdc, rect.left, rect.top, rect.right/2, rect.bottom);
|
|
|
|
DeleteObject ( SelectObject(hdc, hBrush) ) ;
|
|
|
|
hBrush = CreateSolidBrush( GetNearestColor(hdc, cr) );
|
1999-02-28 21:05:11 +01:00
|
|
|
if (hBrush)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hBrush = SelectObject(hdc, hBrush) ;
|
|
|
|
Rectangle(hdc, rect.right/2-1, rect.top, rect.right, rect.bottom);
|
|
|
|
DeleteObject(SelectObject(hdc, hBrush)) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintTriangle [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_PaintTriangle( HWND hDlg, int y)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
long temp;
|
2000-07-23 16:21:38 +02:00
|
|
|
int w = LOWORD(GetDialogBaseUnits());
|
2000-04-24 19:35:11 +02:00
|
|
|
POINT points[3];
|
1999-02-28 21:05:11 +01:00
|
|
|
int height;
|
|
|
|
int oben;
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect;
|
|
|
|
HWND hwnd = GetDlgItem(hDlg, 0x2be);
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6))) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
height = rect.bottom;
|
|
|
|
hDC = GetDC(hDlg);
|
|
|
|
points[0].y = rect.top;
|
2001-01-26 21:40:50 +01:00
|
|
|
points[0].x = rect.right; /* | /| */
|
|
|
|
ClientToScreen(hwnd, points); /* | / | */
|
|
|
|
ScreenToClient(hDlg, points); /* |< | */
|
|
|
|
oben = points[0].y; /* | \ | */
|
|
|
|
/* | \| */
|
2000-04-24 19:35:11 +02:00
|
|
|
temp = (long)height * (long)y;
|
|
|
|
points[0].y = oben + height - temp / (long)MAXVERT;
|
|
|
|
points[1].y = points[0].y + w;
|
|
|
|
points[2].y = points[0].y - w;
|
|
|
|
points[2].x = points[1].x = points[0].x + w;
|
|
|
|
|
|
|
|
FillRect(hDC, &lpp->old3angle, GetClassLongA( hwnd, GCL_HBRBACKGROUND));
|
|
|
|
lpp->old3angle.left = points[0].x;
|
|
|
|
lpp->old3angle.right = points[1].x + 1;
|
|
|
|
lpp->old3angle.top = points[2].y - 1;
|
|
|
|
lpp->old3angle.bottom= points[1].y + 1;
|
|
|
|
Polygon(hDC, points, 3);
|
|
|
|
ReleaseDC(hDlg, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintCross [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_PaintCross( HWND hDlg, int x, int y)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
HDC hDC;
|
2000-04-24 19:35:11 +02:00
|
|
|
int w = GetDialogBaseUnits();
|
|
|
|
HWND hwnd = GetDlgItem(hDlg, 0x2c6);
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER );
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect;
|
|
|
|
POINT point, p;
|
1999-02-28 21:05:11 +01:00
|
|
|
HPEN hPen;
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
hDC = GetDC(hwnd);
|
|
|
|
SelectClipRgn( hDC, CreateRectRgnIndirect(&rect));
|
2000-07-23 16:21:38 +02:00
|
|
|
hPen = CreatePen(PS_SOLID, 2, 0xffffff); /* -white- color */
|
2000-04-24 19:35:11 +02:00
|
|
|
hPen = SelectObject(hDC, hPen);
|
|
|
|
point.x = ((long)rect.right * (long)x) / (long)MAXHORI;
|
|
|
|
point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT;
|
|
|
|
if ( lpp->oldcross.left != lpp->oldcross.right )
|
|
|
|
BitBlt(hDC, lpp->oldcross.left, lpp->oldcross.top,
|
|
|
|
lpp->oldcross.right - lpp->oldcross.left,
|
|
|
|
lpp->oldcross.bottom - lpp->oldcross.top,
|
|
|
|
lpp->hdcMem, lpp->oldcross.left, lpp->oldcross.top, SRCCOPY);
|
|
|
|
lpp->oldcross.left = point.x - w - 1;
|
|
|
|
lpp->oldcross.right = point.x + w + 1;
|
|
|
|
lpp->oldcross.top = point.y - w - 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
lpp->oldcross.bottom = point.y + w + 1;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
MoveToEx(hDC, point.x - w, point.y, &p);
|
2000-04-24 19:35:11 +02:00
|
|
|
LineTo(hDC, point.x + w, point.y);
|
2002-06-01 01:06:46 +02:00
|
|
|
MoveToEx(hDC, point.x, point.y - w, &p);
|
2000-04-24 19:35:11 +02:00
|
|
|
LineTo(hDC, point.x, point.y + w);
|
|
|
|
DeleteObject( SelectObject(hDC, hPen)) ;
|
|
|
|
ReleaseDC(hwnd, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define XSTEPS 48
|
|
|
|
#define YSTEPS 24
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PrepareColorGraph [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static void CC_PrepareColorGraph( HWND hDlg )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int sdif, hdif, xdif, ydif, r, g, b, hue, sat;
|
|
|
|
HWND hwnd = GetDlgItem(hDlg, 0x2c6);
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
HBRUSH hbrush;
|
|
|
|
HDC hdc ;
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect, client;
|
|
|
|
HCURSOR hcursor = SetCursor( LoadCursorA(0, IDC_WAITA) );
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &client);
|
|
|
|
hdc = GetDC(hwnd);
|
1999-02-28 21:05:11 +01:00
|
|
|
lpp->hdcMem = CreateCompatibleDC(hdc);
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp->hbmMem = CreateCompatibleBitmap(hdc, client.right, client.bottom);
|
|
|
|
SelectObject(lpp->hdcMem, lpp->hbmMem);
|
|
|
|
|
|
|
|
xdif = client.right / XSTEPS;
|
|
|
|
ydif = client.bottom / YSTEPS+1;
|
|
|
|
hdif = 239 / XSTEPS;
|
|
|
|
sdif = 240 / YSTEPS;
|
|
|
|
for (rect.left = hue = 0; hue < 239 + hdif; hue += hdif)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.right = rect.left + xdif;
|
|
|
|
rect.bottom = client.bottom;
|
|
|
|
for(sat = 0; sat < 240 + sdif; sat += sdif)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.top = rect.bottom - ydif;
|
|
|
|
r = CC_HSLtoRGB('R', hue, sat, 120);
|
|
|
|
g = CC_HSLtoRGB('G', hue, sat, 120);
|
|
|
|
b = CC_HSLtoRGB('B', hue, sat, 120);
|
|
|
|
hbrush = CreateSolidBrush( RGB(r, g, b));
|
|
|
|
FillRect(lpp->hdcMem, &rect, hbrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
DeleteObject(hbrush);
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.bottom = rect.top;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.left = rect.right;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
SetCursor(hcursor);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintColorGraph [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_PaintColorGraph( HWND hDlg )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd = GetDlgItem( hDlg, 0x2c6 );
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hDC;
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect;
|
1999-02-28 21:05:11 +01:00
|
|
|
if (IsWindowVisible(hwnd)) /* if full size */
|
|
|
|
{
|
|
|
|
if (!lpp->hdcMem)
|
|
|
|
CC_PrepareColorGraph(hDlg); /* should not be necessary */
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hDC = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpp->hdcMem)
|
2000-04-24 19:35:11 +02:00
|
|
|
BitBlt(hDC, 0, 0, rect.right, rect.bottom, lpp->hdcMem, 0, 0, SRCCOPY);
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
WARN("choose color: hdcMem is not defined\n");
|
|
|
|
ReleaseDC(hwnd, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintLumBar [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_PaintLumBar( HWND hDlg, int hue, int sat )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd = GetDlgItem(hDlg, 0x2be);
|
|
|
|
RECT rect, client;
|
|
|
|
int lum, ldif, ydif, r, g, b;
|
1999-02-28 21:05:11 +01:00
|
|
|
HBRUSH hbrush;
|
|
|
|
HDC hDC;
|
|
|
|
|
|
|
|
if (IsWindowVisible(hwnd))
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hDC = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &client);
|
|
|
|
rect = client;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
ldif = 240 / YSTEPS;
|
|
|
|
ydif = client.bottom / YSTEPS+1;
|
|
|
|
for (lum = 0; lum < 240 + ldif; lum += ldif)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.top = max(0, rect.bottom - ydif);
|
|
|
|
r = CC_HSLtoRGB('R', hue, sat, lum);
|
|
|
|
g = CC_HSLtoRGB('G', hue, sat, lum);
|
|
|
|
b = CC_HSLtoRGB('B', hue, sat, lum);
|
|
|
|
hbrush = CreateSolidBrush( RGB(r, g, b) );
|
|
|
|
FillRect(hDC, &rect, hbrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
DeleteObject(hbrush);
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.bottom = rect.top;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH) );
|
|
|
|
ReleaseDC(hwnd, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_EditSetRGB [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_EditSetRGB( HWND hDlg, COLORREF cr )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
char buffer[10];
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
int r = GetRValue(cr);
|
|
|
|
int g = GetGValue(cr);
|
|
|
|
int b = GetBValue(cr);
|
|
|
|
if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp->updating = TRUE;
|
|
|
|
sprintf(buffer, "%d", r);
|
|
|
|
SetWindowTextA( GetDlgItem(hDlg, 0x2c2), buffer);
|
|
|
|
sprintf(buffer, "%d", g);
|
|
|
|
SetWindowTextA( GetDlgItem(hDlg, 0x2c3), buffer);
|
|
|
|
sprintf( buffer, "%d", b );
|
|
|
|
SetWindowTextA( GetDlgItem(hDlg, 0x2c4),buffer);
|
|
|
|
lpp->updating = FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_EditSetHSL [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_EditSetHSL( HWND hDlg, int h, int s, int l )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
char buffer[10];
|
2000-07-23 16:21:38 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp->updating = TRUE;
|
|
|
|
if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp->updating = TRUE;
|
|
|
|
sprintf(buffer, "%d", h);
|
|
|
|
SetWindowTextA( GetDlgItem(hDlg, 0x2bf), buffer);
|
|
|
|
sprintf(buffer, "%d", s);
|
|
|
|
SetWindowTextA( GetDlgItem(hDlg, 0x2c0), buffer);
|
|
|
|
sprintf(buffer, "%d", l);
|
|
|
|
SetWindowTextA( GetDlgItem(hDlg, 0x2c1), buffer);
|
|
|
|
lpp->updating = FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_PaintLumBar(hDlg, h, s);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_SwitchToFullSize [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_SwitchToFullSize( HWND hDlg, COLORREF result, LPRECT lprect )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
EnableWindow( GetDlgItem(hDlg, 0x2cf), FALSE);
|
1999-02-28 21:05:11 +01:00
|
|
|
CC_PrepareColorGraph(hDlg);
|
2000-04-24 19:35:11 +02:00
|
|
|
for (i = 0x2bf; i < 0x2c5; i++)
|
|
|
|
ShowWindow( GetDlgItem(hDlg, i), SW_SHOW);
|
|
|
|
for (i = 0x2d3; i < 0x2d9; i++)
|
|
|
|
ShowWindow( GetDlgItem(hDlg, i), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2c9), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2c8), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 1090), SW_SHOW);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (lprect)
|
2000-04-24 19:35:11 +02:00
|
|
|
SetWindowPos(hDlg, 0, 0, 0, lprect->right-lprect->left,
|
1999-02-28 21:05:11 +01:00
|
|
|
lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2be), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2c5), SW_SHOW);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_EditSetRGB(hDlg, result);
|
|
|
|
CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
|
|
|
|
ShowWindow( GetDlgItem( hDlg, 0x2c6), SW_SHOW);
|
|
|
|
UpdateWindow( GetDlgItem(hDlg, 0x2c6) );
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintPredefColorArray [internal]
|
2000-04-24 19:35:11 +02:00
|
|
|
* Paints the default standard 48 colors
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_PaintPredefColorArray( HWND hDlg, int rows, int cols)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd = GetDlgItem(hDlg, 0x2d0);
|
|
|
|
RECT rect;
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hdc;
|
|
|
|
HBRUSH hBrush;
|
2000-04-24 19:35:11 +02:00
|
|
|
int dx, dy, i, j, k;
|
2000-07-23 16:21:38 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
dx = rect.right / cols;
|
|
|
|
dy = rect.bottom / rows;
|
|
|
|
k = rect.left;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND));
|
|
|
|
for ( j = 0; j < rows; j++ )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
for ( i = 0; i < cols; i++ )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
hBrush = CreateSolidBrush(predefcolors[j][i]);
|
|
|
|
if (hBrush)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hBrush = SelectObject(hdc, hBrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
Rectangle(hdc, rect.left, rect.top,
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
|
|
|
|
rect.left = rect.left + dx;
|
|
|
|
DeleteObject(SelectObject(hdc, hBrush)) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.top = rect.top + dy;
|
|
|
|
rect.left = k;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
2000-07-23 16:21:38 +02:00
|
|
|
if (lpp->hwndFocus == hwnd)
|
|
|
|
CC_DrawCurrentFocusRect(lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintUserColorArray [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
* Paint the 16 user-selected colors
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, COLORREF* lpcr )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd = GetDlgItem(hDlg, 0x2d1);
|
|
|
|
RECT rect;
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hdc;
|
|
|
|
HBRUSH hBrush;
|
2000-04-24 19:35:11 +02:00
|
|
|
int dx, dy, i, j, k;
|
2000-07-23 16:21:38 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
dx = rect.right / cols;
|
|
|
|
dy = rect.bottom / rows;
|
|
|
|
k = rect.left;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = GetDC(hwnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (hdc)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND) );
|
|
|
|
for (j = 0; j < rows; j++)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
for (i = 0; i < cols; i++)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
hBrush = CreateSolidBrush(lpcr[i+j*cols]);
|
|
|
|
if (hBrush)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hBrush = SelectObject(hdc, hBrush) ;
|
|
|
|
Rectangle(hdc, rect.left, rect.top,
|
|
|
|
rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
|
|
|
|
rect.left = rect.left + dx;
|
|
|
|
DeleteObject( SelectObject(hdc, hBrush) ) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.top = rect.top + dy;
|
|
|
|
rect.left = k;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-07-23 16:21:38 +02:00
|
|
|
if (lpp->hwndFocus == hwnd)
|
|
|
|
CC_DrawCurrentFocusRect(lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_HookCallChk [internal]
|
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
static BOOL CC_HookCallChk( LPCHOOSECOLORW lpcc )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
if (lpcc)
|
|
|
|
if(lpcc->Flags & CC_ENABLEHOOK)
|
|
|
|
if (lpcc->lpfnHook)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2000-04-24 19:35:11 +02:00
|
|
|
* CC_WMInitDialog [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int i, res;
|
1999-02-28 21:05:11 +01:00
|
|
|
int r, g, b;
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
RECT rect;
|
|
|
|
POINT point;
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp;
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) );
|
|
|
|
if (b16)
|
|
|
|
{
|
|
|
|
CHOOSECOLORW *ch32;
|
|
|
|
CHOOSECOLOR16 *ch16 = (CHOOSECOLOR16 *) lParam;
|
|
|
|
ch32 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW) );
|
|
|
|
lpp->lpcc = ch32;
|
|
|
|
lpp->lpcc16 = ch16;
|
|
|
|
if (lpp->lpcc16->lStructSize != sizeof(CHOOSECOLOR16) )
|
|
|
|
{
|
|
|
|
EndDialog (hDlg, 0) ;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ch32->lStructSize = sizeof(CHOOSECOLORW);
|
2002-09-06 22:40:42 +02:00
|
|
|
ch32->hwndOwner = HWND_32(ch16->hwndOwner);
|
|
|
|
/* Should be an HINSTANCE but MS made a typo */
|
|
|
|
ch32->hInstance = HWND_32(ch16->hInstance);
|
2000-12-13 21:20:09 +01:00
|
|
|
ch32->lpCustColors = MapSL(ch16->lpCustColors);
|
2000-04-24 19:35:11 +02:00
|
|
|
ch32->lpfnHook = (LPCCHOOKPROC) ch16->lpfnHook; /* only used as flag */
|
|
|
|
ch32->Flags = ch16->Flags;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
lpp->lpcc = (LPCHOOSECOLORW) lParam;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLORW) )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
EndDialog (hDlg, 0) ;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
SetWindowLongA(hDlg, DWL_USER, (LONG)lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (!(lpp->lpcc->Flags & CC_SHOWHELP))
|
2000-04-24 19:35:11 +02:00
|
|
|
ShowWindow( GetDlgItem(hDlg,0x40e), SW_HIDE);
|
2001-01-22 03:13:58 +01:00
|
|
|
lpp->msetrgb = RegisterWindowMessageA(SETRGBSTRINGA);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
#if 0
|
2000-04-24 19:35:11 +02:00
|
|
|
cpos = MAKELONG(5,7); /* init */
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpp->lpcc->Flags & CC_RGBINIT)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
for (i = 0; i < 6; i++)
|
2000-04-24 19:35:11 +02:00
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
if (predefcolors[i][j] == lpp->lpcc->rgbResult)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
cpos = MAKELONG(i,j);
|
1999-02-28 21:05:11 +01:00
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
found:
|
|
|
|
/* FIXME: Draw_a_focus_rect & set_init_values */
|
|
|
|
#endif
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowRect(hDlg, &lpp->fullsize);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hwnd = GetDlgItem(hDlg, 0x2cf);
|
|
|
|
EnableWindow(hwnd, FALSE);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
if (!(lpp->lpcc->Flags & CC_FULLOPEN ) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect = lpp->fullsize;
|
|
|
|
res = rect.bottom - rect.top;
|
|
|
|
hwnd = GetDlgItem(hDlg, 0x2c6); /* cut at left border */
|
|
|
|
point.x = point.y = 0;
|
|
|
|
ClientToScreen(hwnd, &point);
|
|
|
|
ScreenToClient(hDlg,&point);
|
|
|
|
GetClientRect(hDlg, &rect);
|
|
|
|
point.x += GetSystemMetrics(SM_CXDLGFRAME);
|
|
|
|
SetWindowPos(hDlg, 0, 0, 0, point.x, res, SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
|
|
|
|
for (i = 0x2bf; i < 0x2c5; i++)
|
|
|
|
ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
|
|
|
|
for (i = 0x2d3; i < 0x2d9; i++)
|
|
|
|
ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2c9), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2c8), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2c6), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 0x2c5), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, 1090 ), SW_HIDE);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, NULL);
|
2000-07-23 16:21:38 +02:00
|
|
|
res = TRUE;
|
2000-04-24 19:35:11 +02:00
|
|
|
for (i = 0x2bf; i < 0x2c5; i++)
|
|
|
|
SendMessageA( GetDlgItem(hDlg, i), EM_LIMITTEXT, 3, 0); /* max 3 digits: xyz */
|
1999-02-28 21:05:11 +01:00
|
|
|
if (CC_HookCallChk(lpp->lpcc))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
if (b16)
|
2002-09-06 22:40:42 +02:00
|
|
|
res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook,
|
|
|
|
HWND_16(hDlg), WM_INITDIALOG, wParam, lParam);
|
2000-04-24 19:35:11 +02:00
|
|
|
else
|
|
|
|
res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/* Set the initial values of the color chooser dialog */
|
|
|
|
r = GetRValue(lpp->lpcc->rgbResult);
|
|
|
|
g = GetGValue(lpp->lpcc->rgbResult);
|
|
|
|
b = GetBValue(lpp->lpcc->rgbResult);
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
lpp->h = CC_RGBtoHSL('H', r, g, b);
|
|
|
|
lpp->s = CC_RGBtoHSL('S', r, g, b);
|
|
|
|
lpp->l = CC_RGBtoHSL('L', r, g, b);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/* Doing it the long way becaus CC_EditSetRGB/HSL doesn'nt seem to work */
|
|
|
|
SetDlgItemInt(hDlg, 703, lpp->h, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, 704, lpp->s, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, 705, lpp->l, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, 706, r, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, 707, g, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, 708, b, TRUE);
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintTriangle(hDlg, lpp->l);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMCommand [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int r, g, b, i, xx;
|
|
|
|
UINT cokmsg;
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hdc;
|
|
|
|
COLORREF *cr;
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
TRACE("CC_WMCommand wParam=%x lParam=%lx\n", wParam, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case 0x2c2: /* edit notify RGB */
|
|
|
|
case 0x2c3:
|
|
|
|
case 0x2c4:
|
2000-04-24 19:35:11 +02:00
|
|
|
if (notifyCode == EN_UPDATE && !lpp->updating)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
i = CC_CheckDigitsInEdit(hwndCtl, 255);
|
|
|
|
r = GetRValue(lpp->lpcc->rgbResult);
|
|
|
|
g = GetGValue(lpp->lpcc->rgbResult);
|
|
|
|
b= GetBValue(lpp->lpcc->rgbResult);
|
|
|
|
xx = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
switch (wParam)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
case 0x2c2: if ((xx = (i != r))) r = i; break;
|
|
|
|
case 0x2c3: if ((xx = (i != g))) g = i; break;
|
|
|
|
case 0x2c4: if ((xx = (i != b))) b = i; break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (xx) /* something has changed */
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp->lpcc->rgbResult = RGB(r, g, b);
|
|
|
|
CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
lpp->h = CC_RGBtoHSL('H', r, g, b);
|
|
|
|
lpp->s = CC_RGBtoHSL('S', r, g, b);
|
|
|
|
lpp->l = CC_RGBtoHSL('L', r, g, b);
|
|
|
|
CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
|
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintTriangle(hDlg, lpp->l);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case 0x2bf: /* edit notify HSL */
|
|
|
|
case 0x2c0:
|
|
|
|
case 0x2c1:
|
2000-04-24 19:35:11 +02:00
|
|
|
if (notifyCode == EN_UPDATE && !lpp->updating)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240);
|
|
|
|
xx = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
switch (wParam)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break;
|
|
|
|
case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break;
|
|
|
|
case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (xx) /* something has changed */
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
|
|
|
|
g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
|
|
|
|
b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
|
|
|
|
lpp->lpcc->rgbResult = RGB(r, g, b);
|
|
|
|
CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintTriangle(hDlg, lpp->l);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case 0x2cf:
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, &lpp->fullsize);
|
|
|
|
SetFocus( GetDlgItem(hDlg, 0x2bf));
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2c8: /* add colors ... column by column */
|
2000-04-24 19:35:11 +02:00
|
|
|
cr = lpp->lpcc->lpCustColors;
|
|
|
|
cr[(lpp->nextuserdef % 2) * 8 + lpp->nextuserdef / 2] = lpp->lpcc->rgbResult;
|
|
|
|
if (++lpp->nextuserdef == 16)
|
|
|
|
lpp->nextuserdef = 0;
|
|
|
|
CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2c9: /* resulting color */
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = GetDC(hDlg);
|
|
|
|
lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
|
|
|
|
ReleaseDC(hDlg, hdc);
|
|
|
|
CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
r = GetRValue(lpp->lpcc->rgbResult);
|
|
|
|
g = GetGValue(lpp->lpcc->rgbResult);
|
|
|
|
b = GetBValue(lpp->lpcc->rgbResult);
|
|
|
|
lpp->h = CC_RGBtoHSL('H', r, g, b);
|
|
|
|
lpp->s = CC_RGBtoHSL('S', r, g, b);
|
|
|
|
lpp->l = CC_RGBtoHSL('L', r, g, b);
|
|
|
|
CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
|
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintTriangle(hDlg, lpp->l);
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
|
2001-01-22 03:13:58 +01:00
|
|
|
i = RegisterWindowMessageA(HELPMSGSTRINGA);
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lpp->lpcc16)
|
|
|
|
{
|
|
|
|
if (lpp->lpcc->hwndOwner)
|
2000-11-30 20:07:09 +01:00
|
|
|
SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);
|
2000-04-24 19:35:11 +02:00
|
|
|
if ( CC_HookCallChk(lpp->lpcc))
|
2002-09-06 22:40:42 +02:00
|
|
|
CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook,
|
|
|
|
HWND_16(hDlg), WM_COMMAND, psh15,
|
|
|
|
(LPARAM)lpp->lpcc16);
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lpp->lpcc->hwndOwner)
|
|
|
|
SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
|
|
|
|
if ( CC_HookCallChk(lpp->lpcc))
|
|
|
|
CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,
|
|
|
|
WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDOK :
|
2001-01-22 03:13:58 +01:00
|
|
|
cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lpp->lpcc16)
|
|
|
|
{
|
|
|
|
if (lpp->lpcc->hwndOwner)
|
2000-11-30 20:07:09 +01:00
|
|
|
if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))
|
1999-02-28 21:05:11 +01:00
|
|
|
break; /* do NOT close */
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lpp->lpcc->hwndOwner)
|
|
|
|
if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
|
|
|
|
break; /* do NOT close */
|
|
|
|
}
|
|
|
|
if (lpp->lpcc16)
|
|
|
|
{
|
2000-12-13 21:20:09 +01:00
|
|
|
BYTE *ptr = MapSL(lpp->lpcc16->lpCustColors);
|
2000-04-24 19:35:11 +02:00
|
|
|
memcpy(ptr, lpp->lpcc->lpCustColors, sizeof(COLORREF)*16);
|
|
|
|
lpp->lpcc16->rgbResult = lpp->lpcc->rgbResult;
|
|
|
|
}
|
|
|
|
EndDialog(hDlg, 1) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE ;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case IDCANCEL :
|
2000-04-24 19:35:11 +02:00
|
|
|
EndDialog(hDlg, 0) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE ;
|
|
|
|
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMPaint [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = BeginPaint(hDlg, &ps);
|
1999-02-28 21:05:11 +01:00
|
|
|
/* we have to paint dialog children except text and buttons */
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_PaintPredefColorArray(hDlg, 6, 8);
|
|
|
|
CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
|
|
|
|
CC_PaintLumBar(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintTriangle(hDlg, lpp->l);
|
|
|
|
CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
|
1999-02-28 21:05:11 +01:00
|
|
|
CC_PaintColorGraph(hDlg);
|
2000-07-23 16:21:38 +02:00
|
|
|
EndPaint(hDlg, &ps);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMLButtonUp [internal]
|
|
|
|
*/
|
|
|
|
static LRESULT CC_WMLButtonUp( HWND hDlg, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
2000-07-23 16:21:38 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lpp->capturedGraph)
|
|
|
|
{
|
|
|
|
lpp->capturedGraph = 0;
|
|
|
|
ReleaseCapture();
|
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
return 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMMouseMove [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam )
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
int r, g, b;
|
|
|
|
|
|
|
|
if (lpp->capturedGraph)
|
|
|
|
{
|
|
|
|
int *ptrh = NULL, *ptrs = &lpp->l;
|
2002-06-01 01:06:46 +02:00
|
|
|
if (lpp->capturedGraph == 0x2c6)
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
ptrh = &lpp->h;
|
|
|
|
ptrs = &lpp->s;
|
|
|
|
}
|
|
|
|
if (CC_MouseCheckColorGraph( hDlg, lpp->capturedGraph, ptrh, ptrs, lParam))
|
|
|
|
{
|
|
|
|
r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
|
|
|
|
g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
|
|
|
|
b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
|
|
|
|
lpp->lpcc->rgbResult = RGB(r, g, b);
|
|
|
|
CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
CC_EditSetHSL(hDlg,lpp->h, lpp->s, lpp->l);
|
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintTriangle(hDlg, lpp->l);
|
|
|
|
CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ReleaseCapture();
|
|
|
|
lpp->capturedGraph = 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMLButtonDown [internal]
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
int r, g, b, i;
|
|
|
|
i = 0;
|
|
|
|
|
2000-07-23 16:21:38 +02:00
|
|
|
if (CC_MouseCheckPredefColorArray(lpp, hDlg, 0x2d0, 6, 8, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
i = 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-07-23 16:21:38 +02:00
|
|
|
if (CC_MouseCheckUserColorArray(lpp, hDlg, 0x2d1, 2, 8, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
i = 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))
|
|
|
|
{
|
|
|
|
i = 2;
|
|
|
|
lpp->capturedGraph = 0x2c6;
|
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))
|
|
|
|
{
|
|
|
|
i = 2;
|
|
|
|
lpp->capturedGraph = 0x2be;
|
|
|
|
}
|
|
|
|
if ( i == 2 )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
SetCapture(hDlg);
|
|
|
|
r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
|
|
|
|
g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
|
|
|
|
b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
|
|
|
|
lpp->lpcc->rgbResult = RGB(r, g, b);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
if ( i == 1 )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
r = GetRValue(lpp->lpcc->rgbResult);
|
|
|
|
g = GetGValue(lpp->lpcc->rgbResult);
|
|
|
|
b = GetBValue(lpp->lpcc->rgbResult);
|
|
|
|
lpp->h = CC_RGBtoHSL('H', r, g, b);
|
|
|
|
lpp->s = CC_RGBtoHSL('S', r, g, b);
|
|
|
|
lpp->l = CC_RGBtoHSL('L', r, g, b);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (i)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
|
|
|
|
CC_EditSetHSL(hDlg,lpp->h, lpp->s, lpp->l);
|
|
|
|
CC_PaintCross(hDlg, lpp->h, lpp->s);
|
|
|
|
CC_PaintTriangle(hDlg, lpp->l);
|
|
|
|
CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ColorDlgProc32 [internal]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static LRESULT WINAPI ColorDlgProc( HWND hDlg, UINT message,
|
|
|
|
WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
|
|
|
|
int res;
|
2000-07-23 16:21:38 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
if (message != WM_INITDIALOG)
|
|
|
|
{
|
|
|
|
if (!lpp)
|
|
|
|
return FALSE;
|
|
|
|
res = 0;
|
|
|
|
if (CC_HookCallChk(lpp->lpcc))
|
|
|
|
res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, message, wParam, lParam);
|
|
|
|
if ( res )
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: SetRGB message
|
|
|
|
if (message && message == msetrgb)
|
|
|
|
return HandleSetRGB(hDlg, lParam);
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return CC_WMInitDialog(hDlg, wParam, lParam, FALSE);
|
|
|
|
case WM_NCDESTROY:
|
2002-06-01 01:06:46 +02:00
|
|
|
DeleteDC(lpp->hdcMem);
|
|
|
|
DeleteObject(lpp->hbmMem);
|
2000-04-24 19:35:11 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpp);
|
|
|
|
SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam))
|
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2000-04-24 19:35:11 +02:00
|
|
|
case WM_PAINT:
|
|
|
|
if ( CC_WMPaint(hDlg, wParam, lParam))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
if (CC_MouseCheckResultWindow(hDlg, lParam))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
if (CC_WMMouseMove(hDlg, lParam))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
|
|
|
|
if (CC_WMLButtonUp(hDlg, wParam, lParam))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
|
|
|
|
if (CC_WMLButtonDown(hDlg, wParam, lParam))
|
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
return FALSE ;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ColorDlgProc (COMMDLG.8)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2002-09-06 22:40:42 +02:00
|
|
|
LRESULT WINAPI ColorDlgProc16( HWND16 hDlg16, UINT16 message,
|
2000-04-24 19:35:11 +02:00
|
|
|
WPARAM16 wParam, LONG lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
int res;
|
2002-09-06 22:40:42 +02:00
|
|
|
HWND hDlg = HWND_32(hDlg16);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
|
2000-04-24 19:35:11 +02:00
|
|
|
if (message != WM_INITDIALOG)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
if (!lpp)
|
|
|
|
return FALSE;
|
|
|
|
res=0;
|
|
|
|
if (CC_HookCallChk(lpp->lpcc))
|
2002-09-06 22:40:42 +02:00
|
|
|
res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg16, message, wParam, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (res)
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: SetRGB message
|
2000-04-24 19:35:11 +02:00
|
|
|
if (message && message == msetrgb)
|
|
|
|
return HandleSetRGB(hDlg, lParam);
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2000-04-24 19:35:11 +02:00
|
|
|
return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_NCDESTROY:
|
2002-06-01 01:06:46 +02:00
|
|
|
DeleteDC(lpp->hdcMem);
|
|
|
|
DeleteObject(lpp->hbmMem);
|
2000-04-24 19:35:11 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpp->lpcc);
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
|
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
2002-09-06 22:40:42 +02:00
|
|
|
if (CC_WMCommand(hDlg, wParam, lParam,
|
|
|
|
HIWORD(lParam), HWND_32(LOWORD(lParam))))
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
1999-02-28 21:05:11 +01:00
|
|
|
case WM_PAINT:
|
|
|
|
if (CC_WMPaint(hDlg, wParam, lParam))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
if (CC_MouseCheckResultWindow(hDlg,lParam))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2000-04-24 19:35:11 +02:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
if (CC_WMMouseMove(hDlg, lParam))
|
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
|
2000-04-24 19:35:11 +02:00
|
|
|
if (CC_WMLButtonUp(hDlg, wParam, lParam))
|
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
|
|
|
|
if (CC_WMLButtonDown(hDlg, wParam, lParam))
|
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
return FALSE ;
|
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* ChooseColor (COMMDLG.5)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
BOOL16 WINAPI ChooseColor16( LPCHOOSECOLOR16 lpChCol )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HINSTANCE16 hInst;
|
2000-05-23 03:22:35 +02:00
|
|
|
HANDLE16 hDlgTmpl16 = 0, hResource16 = 0;
|
|
|
|
HGLOBAL16 hGlobal16 = 0;
|
|
|
|
BOOL16 bRet = FALSE;
|
2000-04-24 19:35:11 +02:00
|
|
|
LPCVOID template;
|
2000-05-23 03:22:35 +02:00
|
|
|
FARPROC16 ptr;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
TRACE("ChooseColor\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!lpChCol) return FALSE;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
|
|
|
if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
|
2000-05-23 03:22:35 +02:00
|
|
|
hDlgTmpl16 = lpChCol->hInstance;
|
2000-04-24 19:35:11 +02:00
|
|
|
else if (lpChCol->Flags & CC_ENABLETEMPLATE)
|
|
|
|
{
|
|
|
|
HANDLE16 hResInfo;
|
|
|
|
if (!(hResInfo = FindResource16(lpChCol->hInstance,
|
2000-12-13 21:20:09 +01:00
|
|
|
MapSL(lpChCol->lpTemplateName),
|
2000-11-27 22:54:01 +01:00
|
|
|
RT_DIALOGA)))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-23 03:22:35 +02:00
|
|
|
if (!(hDlgTmpl16 = LoadResource16(lpChCol->hInstance, hResInfo)))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-23 03:22:35 +02:00
|
|
|
hResource16 = hDlgTmpl16;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl32;
|
2000-05-23 03:22:35 +02:00
|
|
|
LPCVOID template32;
|
|
|
|
DWORD size;
|
2000-04-24 19:35:11 +02:00
|
|
|
if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-23 03:22:35 +02:00
|
|
|
if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
|
|
|
|
!(template32 = LockResource(hDlgTmpl32)))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-05-23 03:22:35 +02:00
|
|
|
size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
|
|
|
|
hGlobal16 = GlobalAlloc16(0, size);
|
|
|
|
if (!hGlobal16)
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
|
|
|
|
ERR("alloc failure for %ld bytes\n", size);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
template = GlobalLock16(hGlobal16);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!template)
|
2000-05-23 03:22:35 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
|
|
|
|
ERR("global lock failure for %x handle\n", hDlgTmpl16);
|
|
|
|
GlobalFree16(hGlobal16);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
|
|
|
|
hDlgTmpl16 = hGlobal16;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-11-27 22:54:01 +01:00
|
|
|
ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 8);
|
2002-09-06 22:40:42 +02:00
|
|
|
hInst = GetWindowLongA(HWND_32(lpChCol->hwndOwner), GWL_HINSTANCE);
|
2000-05-23 03:22:35 +02:00
|
|
|
bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChCol->hwndOwner,
|
|
|
|
(DLGPROC16) ptr, (DWORD)lpChCol);
|
|
|
|
if (hResource16) FreeResource16(hDlgTmpl16);
|
|
|
|
if (hGlobal16)
|
|
|
|
{
|
|
|
|
GlobalUnlock16(hGlobal16);
|
|
|
|
GlobalFree16(hGlobal16);
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
return bRet;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* ChooseColorW (COMDLG32.@)
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2000-04-24 19:35:11 +02:00
|
|
|
BOOL WINAPI ChooseColorW( LPCHOOSECOLORW lpChCol )
|
|
|
|
{
|
|
|
|
HANDLE hDlgTmpl = 0;
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
LPCVOID template;
|
|
|
|
|
|
|
|
TRACE("ChooseColor\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!lpChCol) return FALSE;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
|
|
|
if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
|
|
|
|
{
|
|
|
|
if (!(template = LockResource(lpChCol->hInstance)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lpChCol->Flags & CC_ENABLETEMPLATE)
|
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
2000-04-24 19:35:11 +02:00
|
|
|
if (!(hResInfo = FindResourceW(lpChCol->hInstance,
|
|
|
|
lpChCol->lpTemplateName,
|
|
|
|
RT_DIALOGW)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource(lpChCol->hInstance, hResInfo)) ||
|
|
|
|
!(template = LockResource(hDlgTmpl)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl;
|
2000-04-24 19:35:11 +02:00
|
|
|
if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
|
|
|
|
!(template = LockResource(hDlgTmpl)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-23 03:22:35 +02:00
|
|
|
bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template, lpChCol->hwndOwner,
|
|
|
|
(DLGPROC)ColorDlgProc, (DWORD)lpChCol);
|
2000-04-24 19:35:11 +02:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* ChooseColorA (COMDLG32.@)
|
2000-04-24 19:35:11 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
BOOL ret;
|
2000-04-25 21:53:04 +02:00
|
|
|
LPCHOOSECOLORW lpcc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW));
|
2000-04-24 19:35:11 +02:00
|
|
|
lpcc->lStructSize = sizeof(*lpcc);
|
|
|
|
lpcc->hwndOwner = lpChCol->hwndOwner;
|
|
|
|
lpcc->hInstance = lpChCol->hInstance;
|
|
|
|
lpcc->rgbResult = lpChCol->rgbResult;
|
|
|
|
lpcc->lpCustColors = lpChCol->lpCustColors;
|
|
|
|
lpcc->Flags = lpChCol->Flags;
|
|
|
|
lpcc->lCustData = lpChCol->lCustData;
|
|
|
|
lpcc->lpfnHook = (LPCCHOOKPROC) lpChCol->lpfnHook;
|
2000-06-25 14:51:14 +02:00
|
|
|
if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
|
2002-01-04 19:23:46 +01:00
|
|
|
if (HIWORD(lpChCol->lpTemplateName)) {
|
|
|
|
INT len = MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, NULL, 0);
|
|
|
|
lpcc->lpTemplateName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
2002-01-21 19:00:24 +01:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, (LPWSTR)lpcc->lpTemplateName, len );
|
2002-01-04 19:23:46 +01:00
|
|
|
} else {
|
2000-06-25 14:51:14 +02:00
|
|
|
lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;
|
2002-01-04 19:23:46 +01:00
|
|
|
}
|
2000-06-25 14:51:14 +02:00
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
ret = ChooseColorW(lpcc);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-25 21:53:04 +02:00
|
|
|
if (ret)
|
2000-04-24 19:35:11 +02:00
|
|
|
lpChCol->rgbResult = lpcc->rgbResult;
|
2000-06-25 14:51:14 +02:00
|
|
|
if (HIWORD(lpcc->lpTemplateName)) HeapFree(GetProcessHeap(), 0, (LPSTR)lpcc->lpTemplateName);
|
2000-04-25 21:53:04 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpcc);
|
2000-04-24 19:35:11 +02:00
|
|
|
return ret;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|