Author: cfinck Date: Fri Nov 16 00:38:36 2007 New Revision: 30475
URL: http://svn.reactos.org/svn/reactos?rev=30475&view=rev Log: - Add new spectrum bitmaps for 4bpp, 8bpp and 16-32bpp. The 8bpp one can probably be done better, but at least it's suitable ;-) As we use StretchBlt in the code, the bitmaps are very small, so they are stretched to the full size at runtime. - Change the current spectrum bitmap, when the user selects another color depth - Enable support for 4bpp color depth - Fix a bug in "monslctl.c", which broke building under MSVC
Added: trunk/reactos/dll/cpl/desk/resources/spectrum_16.bmp (with props) trunk/reactos/dll/cpl/desk/resources/spectrum_4.bmp (with props) trunk/reactos/dll/cpl/desk/resources/spectrum_8.bmp (with props) Removed: trunk/reactos/dll/cpl/desk/resources/spectrum.bmp Modified: trunk/reactos/dll/cpl/desk/desk.h trunk/reactos/dll/cpl/desk/desk.rc trunk/reactos/dll/cpl/desk/monslctl.c trunk/reactos/dll/cpl/desk/resource.h trunk/reactos/dll/cpl/desk/settings.c
Modified: trunk/reactos/dll/cpl/desk/desk.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/desk.h?rev=304... ============================================================================== --- trunk/reactos/dll/cpl/desk/desk.h (original) +++ trunk/reactos/dll/cpl/desk/desk.h Fri Nov 16 00:38:36 2007 @@ -48,7 +48,8 @@
ULONG __cdecl DbgPrint(PCCH Format,...);
-#define MAX_DESK_PAGES 32 +#define MAX_DESK_PAGES 32 +#define NUM_SPECTRUM_BITMAPS 3
/* As slider control can't contain user data, we have to keep an * array of RESOLUTION_INFO to have our own associated data.
Modified: trunk/reactos/dll/cpl/desk/desk.rc URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/desk.rc?rev=30... ============================================================================== --- trunk/reactos/dll/cpl/desk/desk.rc (original) +++ trunk/reactos/dll/cpl/desk/desk.rc Fri Nov 16 00:38:36 2007 @@ -15,6 +15,9 @@ IDC_DESK_ICON ICON "resources/applet.ico" IDC_DESK_ICON2 ICON "resources/applet.ico" IDC_MONITOR BITMAP "resources/monitor.bmp" -IDB_SPECTRUM BITMAP "resources/spectrum.bmp" + +IDB_SPECTRUM_4 BITMAP "resources/spectrum_4.bmp" +IDB_SPECTRUM_8 BITMAP "resources/spectrum_8.bmp" +IDB_SPECTRUM_16 BITMAP "resources/spectrum_16.bmp"
#include "rsrc.rc"
Modified: trunk/reactos/dll/cpl/desk/monslctl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/monslctl.c?rev... ============================================================================== --- trunk/reactos/dll/cpl/desk/monslctl.c (original) +++ trunk/reactos/dll/cpl/desk/monslctl.c Fri Nov 16 00:38:36 2007 @@ -895,7 +895,7 @@
/* Paint the dragging monitor last */ if (infoPtr->IsDraggingMonitor && - (DWORD)infoPtr->DraggingMonitor >= 0) + infoPtr->DraggingMonitor >= 0) { MonSelRectToScreen(infoPtr, &infoPtr->rcDragging,
Modified: trunk/reactos/dll/cpl/desk/resource.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/resource.h?rev... ============================================================================== --- trunk/reactos/dll/cpl/desk/resource.h (original) +++ trunk/reactos/dll/cpl/desk/resource.h Fri Nov 16 00:38:36 2007 @@ -66,7 +66,10 @@ #define IDC_SETTINGS_ADVANCED 205 #define IDC_SETTINGS_MONSEL 206 #define IDC_SETTINGS_SPECTRUM 207 -#define IDB_SPECTRUM 208 + +#define IDB_SPECTRUM_4 208 +#define IDB_SPECTRUM_8 209 +#define IDB_SPECTRUM_16 210
#define IDR_PREVIEW_MENU 2100 #define ID_MENU_NORMAL 2101
Removed: trunk/reactos/dll/cpl/desk/resources/spectrum.bmp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/resources/spec... ============================================================================== Binary file - no diff available.
Added: trunk/reactos/dll/cpl/desk/resources/spectrum_16.bmp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/resources/spec... ============================================================================== Binary file - no diff available.
Propchange: trunk/reactos/dll/cpl/desk/resources/spectrum_16.bmp ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
Added: trunk/reactos/dll/cpl/desk/resources/spectrum_4.bmp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/resources/spec... ============================================================================== Binary file - no diff available.
Propchange: trunk/reactos/dll/cpl/desk/resources/spectrum_4.bmp ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
Added: trunk/reactos/dll/cpl/desk/resources/spectrum_8.bmp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/resources/spec... ============================================================================== Binary file - no diff available.
Propchange: trunk/reactos/dll/cpl/desk/resources/spectrum_8.bmp ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream
Modified: trunk/reactos/dll/cpl/desk/settings.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/settings.c?rev... ============================================================================== --- trunk/reactos/dll/cpl/desk/settings.c (original) +++ trunk/reactos/dll/cpl/desk/settings.c Fri Nov 16 00:38:36 2007 @@ -15,9 +15,9 @@ { PDISPLAY_DEVICE_ENTRY DisplayDeviceList; PDISPLAY_DEVICE_ENTRY CurrentDisplayDevice; - HBITMAP hBitmap; - int cxSource; - int cySource; + HBITMAP hSpectrumBitmaps[NUM_SPECTRUM_BITMAPS]; + int cxSource[NUM_SPECTRUM_BITMAPS]; + int cySource[NUM_SPECTRUM_BITMAPS]; } GLOBAL_DATA, *PGLOBAL_DATA;
@@ -80,7 +80,8 @@
while (EnumDisplaySettingsEx(DeviceName, iMode, &devmode, dwFlags)) { - if ((devmode.dmBitsPerPel==8 || + if ((devmode.dmBitsPerPel==4 || + devmode.dmBitsPerPel==8 || devmode.dmBitsPerPel==16 || devmode.dmBitsPerPel==24 || devmode.dmBitsPerPel==32) && @@ -285,6 +286,7 @@ BITMAP bitmap; DWORD Result = 0; DWORD iDevNum = 0; + INT i; DISPLAY_DEVICE displayDevice; PGLOBAL_DATA pGlobalData;
@@ -362,15 +364,45 @@ } }
- /* init the color spectrum*/ - pGlobalData->hBitmap = LoadImageW(hApplet, MAKEINTRESOURCEW(IDB_SPECTRUM), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); - if (pGlobalData->hBitmap != NULL) - { - GetObjectW(pGlobalData->hBitmap, sizeof(BITMAP), &bitmap); - - pGlobalData->cxSource = bitmap.bmWidth; - pGlobalData->cySource = bitmap.bmHeight; - } + /* Initialize the color spectrum bitmaps */ + for(i = 0; i < NUM_SPECTRUM_BITMAPS; i++) + { + pGlobalData->hSpectrumBitmaps[i] = LoadImageW(hApplet, MAKEINTRESOURCEW(IDB_SPECTRUM_4 + i), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); + + if (pGlobalData->hSpectrumBitmaps[i] != NULL) + { + GetObjectW(pGlobalData->hSpectrumBitmaps[i], sizeof(BITMAP), &bitmap); + + pGlobalData->cxSource[i] = bitmap.bmWidth; + pGlobalData->cySource[i] = bitmap.bmHeight; + } + } +} + +/* Get the ID for GLOBAL_DATA::hSpectrumBitmaps */ +static VOID +ShowColorSpectrum(IN HDC hDC, IN LPRECT client, IN DWORD BitsPerPel, IN PGLOBAL_DATA pGlobalData) +{ + HDC hdcMem; + hdcMem = CreateCompatibleDC(hDC); + + if (hdcMem) + { + INT iBitmap; + + switch(BitsPerPel) + { + case 4: iBitmap = 0; break; + case 8: iBitmap = 1; break; + default: iBitmap = 2; + } + + SelectObject(hdcMem, pGlobalData->hSpectrumBitmaps[iBitmap]); + StretchBlt(hDC, client->left, client->top, client->right - client->left, + client->bottom - client->top, hdcMem, 0, 0, + pGlobalData->cxSource[iBitmap], pGlobalData->cySource[iBitmap], SRCCOPY); + DeleteDC(hdcMem); + } }
static VOID @@ -383,11 +415,18 @@ PSETTINGS_ENTRY Current; DWORD dmNewBitsPerPel; DWORD index; - TCHAR Buffer[64]; - - SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, WM_GETTEXT, (WPARAM)(sizeof(Buffer) / sizeof(TCHAR)), (LPARAM)Buffer); - index = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)Buffer); + HDC hSpectrumDC; + HWND hSpectrumControl; + RECT client; + + index = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_GETCURSEL, 0, 0); dmNewBitsPerPel = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_GETITEMDATA, index, 0); + + /* Show a new spectrum bitmap */ + hSpectrumControl = GetDlgItem(hwndDlg, IDC_SETTINGS_SPECTRUM); + hSpectrumDC = GetDC(hSpectrumControl); + GetClientRect(hSpectrumControl, &client); + ShowColorSpectrum(hSpectrumDC, &client, dmNewBitsPerPel, pGlobalData);
/* find if new parameters are valid */ Current = pGlobalData->CurrentDisplayDevice->CurrentSettings; @@ -585,20 +624,10 @@ { LPDRAWITEMSTRUCT lpDrawItem; lpDrawItem = (LPDRAWITEMSTRUCT) lParam; + if(lpDrawItem->CtlID == IDC_SETTINGS_SPECTRUM) - { - HDC hdcMem; - hdcMem = CreateCompatibleDC(lpDrawItem->hDC); - if (hdcMem != NULL) - { - SelectObject(hdcMem, pGlobalData->hBitmap); - StretchBlt(lpDrawItem->hDC, lpDrawItem->rcItem.left, lpDrawItem->rcItem.top, - lpDrawItem->rcItem.right - lpDrawItem->rcItem.left, - lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top, - hdcMem, 0, 0, pGlobalData->cxSource, pGlobalData->cySource, SRCCOPY); - DeleteDC(hdcMem); - } - } + ShowColorSpectrum(lpDrawItem->hDC, &lpDrawItem->rcItem, pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel, pGlobalData); + break; } case WM_COMMAND: @@ -784,6 +813,8 @@
case WM_DESTROY: { + INT i; + PDISPLAY_DEVICE_ENTRY Current = pGlobalData->DisplayDeviceList; while (Current != NULL) { @@ -801,8 +832,11 @@
HeapFree(GetProcessHeap(), 0, pGlobalData);
- if (pGlobalData->hBitmap) - DeleteObject(pGlobalData->hBitmap); + for(i = 0; i < NUM_SPECTRUM_BITMAPS; i++) + { + if(pGlobalData->hSpectrumBitmaps[i]) + DeleteObject(pGlobalData->hSpectrumBitmaps[i]); + } } } return FALSE;