My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
#include <CtrlCore/CtrlCore.h>

#ifdef GUI_WINGL

NAMESPACE_UPP

#define LLOG(x) //LOG(x)

bool GetShift() { return !!(GetKeyState(VK_SHIFT) & 0x8000); }
bool GetCtrl() { return !!(GetKeyState(VK_CONTROL) & 0x8000); }
bool GetAlt() { return !!(GetKeyState(VK_MENU) & 0x8000); }
bool GetCapsLock() { return !!(GetKeyState(VK_CAPITAL) & 1); }
bool GetMouseLeft() { return !!(GetKeyState(VK_LBUTTON) & 0x8000); }
bool GetMouseRight() { return !!(GetKeyState(VK_RBUTTON) & 0x8000); }
bool GetMouseMiddle() { return !!(GetKeyState(VK_MBUTTON) & 0x8000); }

dword glKEYtoK(dword chr) {
if(chr == VK_TAB)
chr = K_TAB;
else
if(chr == VK_SPACE)
chr = K_SPACE;
else
if(chr == VK_RETURN)
chr = K_RETURN;
else
chr = chr + K_DELTA;
if(chr == K_ALT_KEY || chr == K_CTRL_KEY || chr == K_SHIFT_KEY)
return chr;
if(GetCtrl()) chr |= K_CTRL;
if(GetAlt()) chr |= K_ALT;
if(GetShift()) chr |= K_SHIFT;
return chr;
}

#ifdef _DEBUG

#define x_MSG(x) { x, #x },

Tuple2<int, const char *> sWinMsg[] = {
#include <CtrlCore/Win32Msg.i>
{0, NULL}
};

#endif

LRESULT CALLBACK glWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
GuiLock __;
#ifdef _DEBUG
Tuple2<int, const char *> *x = FindTuple(sWinMsg, __countof(sWinMsg), message);
if(x) {
LLOG(x->b << ", wParam: " << wParam << ", lParam: " << lParam);
}
#endif
// LLOG("Ctrl::WindowProc(" << message << ") in " << ::Name(this) << ", focus " << (void *)::GetFocus());
switch(message) {
case WM_DESTROY:
DestroyGl();
break;
case WM_LBUTTONDOWN:
Ctrl::DoMouseGl(Ctrl::LEFTDOWN, Point((dword)lParam));
return 0L;
case WM_LBUTTONUP:
Ctrl::DoMouseGl(Ctrl::LEFTUP, Point((dword)lParam));
return 0L;
case WM_LBUTTONDBLCLK:
Ctrl::DoMouseGl(Ctrl::LEFTDOUBLE, Point((dword)lParam));
return 0L;
case WM_RBUTTONDOWN:
Ctrl::DoMouseGl(Ctrl::RIGHTDOWN, Point((dword)lParam));
return 0L;
case WM_RBUTTONUP:
Ctrl::DoMouseGl(Ctrl::RIGHTUP, Point((dword)lParam));
return 0L;
case WM_RBUTTONDBLCLK:
Ctrl::DoMouseGl(Ctrl::RIGHTDOUBLE, Point((dword)lParam));
return 0L;
case WM_MBUTTONDOWN:
Ctrl::DoMouseGl(Ctrl::MIDDLEDOWN, Point((dword)lParam));
return 0L;
case WM_MBUTTONUP:
Ctrl::DoMouseGl(Ctrl::MIDDLEUP, Point((dword)lParam));
return 0L;
case WM_MBUTTONDBLCLK:
Ctrl::DoMouseGl(Ctrl::MIDDLEDOUBLE, Point((dword)lParam));
return 0L;
case WM_MOUSEMOVE:
Ctrl::DoMouseGl(Ctrl::MOUSEMOVE, Point((dword)lParam));
return 0L;
case 0x20a: // WM_MOUSEWHEEL:
{
Point p(0, 0);
::ClientToScreen(hwnd, p);
Ctrl::DoMouseGl(Ctrl::MOUSEWHEEL, Point((dword)lParam) - p, (short)HIWORD(wParam));
}
return 0L;
case WM_SETCURSOR:
if(LOWORD((dword)lParam) == HTCLIENT) {
SetCursor(NULL);
return TRUE;
}
break;
// case WM_MENUCHAR:
// return MAKELONG(0, MNC_SELECT);
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_CHAR:
// ignorekeyup = false;
case WM_KEYUP:
case WM_SYSKEYUP:
{
String msgdump;
switch(message)
{
case WM_KEYDOWN: msgdump << "WM_KEYDOWN"; break;
case WM_KEYUP: msgdump << "WM_KEYUP"; break;
case WM_SYSKEYDOWN: msgdump << "WM_SYSKEYDOWN"; break;
case WM_SYSKEYUP: msgdump << "WM_SYSKEYUP"; break;
case WM_CHAR: msgdump << "WM_CHAR"; break;
}
msgdump << " wParam = 0x" << FormatIntHex(wParam, 8)
<< ", lParam = 0x" << FormatIntHex(lParam, 8);
LLOG(msgdump);
dword keycode = 0;
if(message == WM_KEYDOWN) {
keycode = glKEYtoK((dword)wParam);
if(keycode == K_SPACE)
keycode = 0;
}
else
if(message == WM_KEYUP)
keycode = glKEYtoK((dword)wParam) | K_KEYUP;
else
if(message == WM_SYSKEYDOWN /*&& ((lParam & 0x20000000) || wParam == VK_F10)*/)
keycode = glKEYtoK((dword)wParam);
else
if(message == WM_SYSKEYUP /*&& ((lParam & 0x20000000) || wParam == VK_F10)*/)
keycode = glKEYtoK((dword)wParam) | K_KEYUP;
else
if(message == WM_CHAR && wParam != 127 && wParam > 32 || wParam == 32 && glKEYtoK(VK_SPACE) == K_SPACE)
keycode = (dword)wParam;
bool b = false;
if(keycode)
b = Ctrl::DoKeyGl(keycode, LOWORD(lParam));
// LOG("key processed = " << b);
// if(b || (message == WM_SYSKEYDOWN || message == WM_SYSKEYUP)
// && wParam != VK_F4 && !PassWindowsKey((dword)wParam)) // 17.11.2003 Mirek -> invoke system menu
// return 0L;
break;
}
break;
// case WM_GETDLGCODE:
// return wantfocus ? 0 : DLGC_STATIC;
case WM_ERASEBKGND:
return 1L;
case WM_SIZE:
{
//ActivateGlContext();
Ctrl::SetWindowSize(Size(LOWORD(lParam), HIWORD(lParam)));
Size sz = Ctrl::GetScreenSize();
screenFbo0.Resize(sz.cx, sz.cy);
screenFbo1.Resize(sz.cx, sz.cy);
return 0L;
}
case WM_HELP:
return TRUE;
case WM_CLOSE:
Ctrl::EndSession();
return 0L;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}

END_UPP_NAMESPACE

#endif

Change log

r4365 by unodgs on Jan 6, 2012   Diff
WinGL: Added painting through fbo, added
blur shader, fixed children clipping,
optimized painting a bit
Go to: 
Project members, sign in to write a code review

Older revisions

r4204 by unodgs on Nov 26, 2011   Diff
WinGL: Added possibility to change
texture filtering mode in Bind. Made
top frame's title bar gradient
background smoother
r3765 by unodgs on Aug 15, 2011   Diff
Rainbow: WinGL..
r3683 by unodgs on Jul 20, 2011   Diff
Rainbow: WinGL..
All revisions of this file

File info

Size: 4843 bytes, 177 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting