Mercurial > vba-linux
view src/win32/ColorControl.cpp @ 4:5f6f2134e8ce
apu appears to not be used
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:35:58 -0600 |
parents | f9f4f1b99eed |
children |
line wrap: on
line source
1 // ColorControl.cpp : implementation file2 //4 #include "stdafx.h"5 #include "ColorControl.h"7 bool ColorControl::isRegistered = false;9 /////////////////////////////////////////////////////////////////////////////10 // ColorControl12 ColorControl::ColorControl()13 {14 color = 0;15 registerClass();16 }18 ColorControl::~ColorControl()19 {20 }23 BEGIN_MESSAGE_MAP(ColorControl, CWnd)24 //{{AFX_MSG_MAP(ColorControl)25 ON_WM_PAINT()26 ON_WM_ERASEBKGND()27 //}}AFX_MSG_MAP28 END_MESSAGE_MAP()31 /////////////////////////////////////////////////////////////////////////////32 // ColorControl message handlers34 void ColorControl::OnPaint()35 {36 CPaintDC dc(this); // device context for painting37 }39 BOOL ColorControl::OnEraseBkgnd(CDC* pDC)40 {41 int r = (color & 0x1f) << 3;42 int g = (color & 0x3e0) >> 2;43 int b = (color & 0x7c00) >> 7;45 CBrush br;46 br.CreateSolidBrush(RGB(r,g,b));48 RECT rect;49 GetClientRect(&rect);50 pDC->FillRect(&rect,&br);51 pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT);52 br.DeleteObject();53 return TRUE;54 }56 void ColorControl::setColor(u16 c)57 {58 color = c;59 Invalidate();60 }62 void ColorControl::registerClass()63 {64 if(!isRegistered) {65 WNDCLASS wc;66 ZeroMemory(&wc, sizeof(wc));67 wc.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;68 wc.lpfnWndProc = (WNDPROC)::DefWindowProc;69 wc.hInstance = AfxGetInstanceHandle();70 wc.hIcon = NULL;71 wc.hCursor = LoadCursor(NULL, IDC_ARROW);72 wc.hbrBackground = (HBRUSH )GetStockObject(BLACK_BRUSH);73 wc.lpszMenuName = NULL;74 wc.lpszClassName = "VbaColorControl";75 AfxRegisterClass(&wc);76 isRegistered = true;77 }78 }