ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

palette.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:     PAINT for ReactOS
00003  * LICENSE:     LGPL
00004  * FILE:        base/applications/paint/palette.c
00005  * PURPOSE:     Window procedure of the palette window
00006  * PROGRAMMERS: Benedikt Freisen
00007  */
00008 
00009 /* INCLUDES *********************************************************/
00010 
00011 #include "precomp.h"
00012 
00013 /* FUNCTIONS ********************************************************/
00014 
00015 LRESULT CALLBACK
00016 PalWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
00017 {
00018     switch (message)
00019     {
00020         case WM_PAINT:
00021         {
00022             RECT rc = { 0, 0, 31, 32 };
00023             HDC hDC = GetDC(hwnd);
00024             HPEN oldPen;
00025             HBRUSH oldBrush;
00026             int i, a, b;
00027 
00028             DefWindowProc(hwnd, message, wParam, lParam);
00029 
00030             for(b = 2; b < 30; b++)
00031                 for(a = 2; a < 29; a++)
00032                     if ((a + b) % 2 == 1)
00033                         SetPixel(hDC, a, b, GetSysColor(COLOR_BTNHILIGHT));
00034 
00035             DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
00036             DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_TOPLEFT | BF_BOTTOMRIGHT);
00037             SetRect(&rc, 11, 12, 26, 27);
00038             DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
00039             oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
00040             oldBrush = SelectObject(hDC, CreateSolidBrush(bgColor));
00041             Rectangle(hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1);
00042             DeleteObject(SelectObject(hDC, oldBrush));
00043             SetRect(&rc, 4, 5, 19, 20);
00044             DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
00045             oldBrush = SelectObject(hDC, CreateSolidBrush(fgColor));
00046             Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
00047             DeleteObject(SelectObject(hDC, oldBrush));
00048             DeleteObject(SelectObject(hDC, oldPen));
00049 
00050             for(i = 0; i < 28; i++)
00051             {
00052                 SetRect(&rc, 31 + (i % 14) * 16,
00053                         0 + (i / 14) * 16, 16 + 31 + (i % 14) * 16, 16 + 0 + (i / 14) * 16);
00054                 DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
00055                 DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT);
00056                 oldPen = SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
00057                 oldBrush = SelectObject(hDC, CreateSolidBrush(palColors[i]));
00058                 Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
00059                 DeleteObject(SelectObject(hDC, oldBrush));
00060                 DeleteObject(SelectObject(hDC, oldPen));
00061             }
00062             ReleaseDC(hwnd, hDC);
00063             break;
00064         }
00065         case WM_LBUTTONDOWN:
00066             if (LOWORD(lParam) >= 31)
00067             {
00068                 fgColor = palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14];
00069                 SendMessage(hwnd, WM_PAINT, 0, 0);
00070             }
00071             break;
00072         case WM_RBUTTONDOWN:
00073             if (LOWORD(lParam) >= 31)
00074             {
00075                 bgColor = palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14];
00076                 SendMessage(hwnd, WM_PAINT, 0, 0);
00077             }
00078             break;
00079         case WM_LBUTTONDBLCLK:
00080             if (LOWORD(lParam) >= 31)
00081                 if (ChooseColor(&choosecolor))
00082                 {
00083                     palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14] =
00084                         choosecolor.rgbResult;
00085                     fgColor = choosecolor.rgbResult;
00086                     SendMessage(hwnd, WM_PAINT, 0, 0);
00087                 }
00088             break;
00089         case WM_RBUTTONDBLCLK:
00090             if (LOWORD(lParam) >= 31)
00091                 if (ChooseColor(&choosecolor))
00092                 {
00093                     palColors[(LOWORD(lParam) - 31) / 16 + (HIWORD(lParam) / 16) * 14] =
00094                         choosecolor.rgbResult;
00095                     bgColor = choosecolor.rgbResult;
00096                     SendMessage(hwnd, WM_PAINT, 0, 0);
00097                 }
00098             break;
00099 
00100         default:
00101             return DefWindowProc(hwnd, message, wParam, lParam);
00102     }
00103 
00104     return 0;
00105 }

Generated on Sat May 26 2012 04:16:00 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.