-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathC64DropPalette.cpp
177 lines (129 loc) · 3.41 KB
/
C64DropPalette.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
Pixcen - A windows platform low level pixel editor for C64
Copyright (C) 2013 John Hammarberg ([email protected])
This file is part of Pixcen.
Pixcen is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Pixcen 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with Pixcen. If not, see <http://www.gnu.org/licenses/>.
*/
// C64DropPalette.cpp : implementation file
//
#include "stdafx.h"
#include "Pixcen.h"
#include "C64DropPalette.h"
#include "C64Col.h"
#include "Resource.h"
// C64DropPalette
IMPLEMENT_DYNAMIC(C64DropPalette, CWnd)
C64DropPalette::C64DropPalette()
{
}
C64DropPalette::~C64DropPalette()
{
}
BOOL C64DropPalette::Create(int x, int y, CWnd *pParent, int data)
{
m_pParent = pParent;
m_data = data;
LPCTSTR pClass=AfxRegisterWndClass(CS_DROPSHADOW|CS_HREDRAW,0,0,0);
const int SIZE = 16;
BOOL n= CreateEx(
0,
pClass, _T(""),
WS_POPUP|WS_BORDER,
x, y,
SIZE*2+2, SIZE*12+2,
pParent->GetSafeHwnd(), (HMENU)0, (LPVOID)NULL);
m_Image.LoadFromResource(AfxGetApp()->m_hInstance, IDB_BITMAP_DROP_PALETTE);
return n;
}
BEGIN_MESSAGE_MAP(C64DropPalette, CWnd)
ON_WM_PAINT()
ON_WM_KILLFOCUS()
ON_WM_DESTROY()
ON_WM_LBUTTONDOWN()
// ON_COMMAND(ID_EDIT_REDO, &C64DropPalette::OnEditRedo)
END_MESSAGE_MAP()
// C64DropPalette message handlers
void C64DropPalette::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
CRect rc;
GetClientRect(rc);
/*
int x,y;
int h=rc.bottom/8;
int w=rc.right/2;
for(x=0;x<2;x++)
{
for(y=0;y<8;y++)
{
dc.FillSolidRect(x*w,y*h,w,h,g_Vic2[x*8+y]);
}
}
*/
//m_Ima
m_Image.StretchBlt(dc, rc);
}
void C64DropPalette::OnKillFocus(CWnd* pNewWnd)
{
CWnd::OnKillFocus(pNewWnd);
// TODO: Add your message handler code here
DestroyWindow();
}
void C64DropPalette::OnDestroy()
{
CWnd::OnDestroy();
// TODO: Add your message handler code here
delete this;
}
void C64DropPalette::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rc;
GetClientRect(rc);
int h=rc.bottom/12;
int w=rc.right/2;
int x=point.x/w;
int y=point.y/h;
if(y>=1 && y<=8)
{
//Color picked
m_pParent->PostMessage(UM_DROP_PAL_SEL, x*8+(y-1), m_data);
}
else if(y==0)
{
//Upp
m_pParent->PostMessage(UM_DROP_PAL_SEL, 100, m_data);
}
else if(y==9)
{
//Cripple
m_pParent->PostMessage(UM_DROP_PAL_SEL, 101, m_data);
}
else if(y==10)
{
//Lock
m_pParent->PostMessage(UM_DROP_PAL_SEL, 102, m_data);
}
else if(y==11)
{
//Down
m_pParent->PostMessage(UM_DROP_PAL_SEL, 103, m_data);
}
DestroyWindow();
//CWnd::OnLButtonDown(nFlags, point);
}
//void C64DropPalette::OnEditRedo()
//{
// // TODO: Add your command handler code here
//}