More WIN32 fixes from Gustavo Hime.
git-svn-id: file:///fltk/svn/fltk/trunk@13 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
255e7fb39b
commit
67d2f102d9
@ -83,10 +83,10 @@ extern MSG fl_msg;
|
||||
|
||||
extern HDC fl_makeDC(HBITMAP);
|
||||
#define fl_begin_offscreen(b) \
|
||||
HDC _sgc=fl_gc; Window _sw=fl_window; fl_gc=fl_makeDC(b); fl_window=b;
|
||||
HDC _sgc=fl_gc; Window _sw=fl_window; fl_gc=fl_makeDC(b); fl_window=(HWND)b
|
||||
|
||||
#define fl_end_offscreen() \
|
||||
ReleaseDC(fl_window,fl_gc); fl_window=_sw; fl_gc = _sgc
|
||||
DeleteDC(fl_gc); fl_window=_sw; fl_gc = _sgc
|
||||
|
||||
void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP pixmap,int srcx,int srcy);
|
||||
#define fl_delete_offscreen(bitmap) DeleteObject(bitmap);
|
||||
|
@ -72,7 +72,7 @@ void fl_copy_offscreen(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy)
|
||||
HDC new_gc = CreateCompatibleDC(fl_gc);
|
||||
SelectObject(new_gc, bitmap);
|
||||
BitBlt(fl_gc, x, y, w, h, new_gc, srcx, srcy, SRCCOPY);
|
||||
ReleaseDC(bitmap, new_gc);
|
||||
DeleteDC(new_gc);
|
||||
}
|
||||
|
||||
extern void fl_restore_clip();
|
||||
@ -95,12 +95,13 @@ void Fl_Double_Window::flush() {
|
||||
clear_damage(~0);
|
||||
}
|
||||
#ifdef WIN32
|
||||
fl_clip_region(i->region); i->region = 0;
|
||||
if (DAMAGE_TEST()) {
|
||||
HDC _sgc = fl_gc;
|
||||
fl_gc = fl_makeDC(i->other_xid);
|
||||
fl_restore_clip(); // duplicate region into new gc
|
||||
draw();
|
||||
ReleaseDC(i->other_xid, fl_gc);
|
||||
DeleteDC(fl_gc);
|
||||
fl_gc = _sgc;
|
||||
}
|
||||
#else // X:
|
||||
|
@ -161,29 +161,29 @@ static int mouse_event(Fl_Window *window, int what, int button,
|
||||
// convert a MSWindows VK_x to an Fltk (X) Keysym:
|
||||
// See also the inverse converter in Fl_get_key_win32.C
|
||||
// This table is in numeric order by VK:
|
||||
static const struct {unsigned short vk, fltk, extended;} vktab[] = {
|
||||
static const struct {unsigned short vk, fltk;} vktab[] = {
|
||||
{VK_BACK, FL_BackSpace},
|
||||
{VK_TAB, FL_Tab},
|
||||
{VK_CLEAR, FL_KP+'5'},
|
||||
{VK_RETURN, FL_Enter, FL_KP_Enter},
|
||||
{VK_SHIFT, FL_Shift_L, FL_Shift_R},
|
||||
{VK_CONTROL, FL_Control_L, FL_Control_R},
|
||||
{VK_MENU, FL_Alt_L, FL_Alt_R},
|
||||
{VK_RETURN, FL_Enter},
|
||||
{VK_SHIFT, FL_Shift_L},
|
||||
{VK_CONTROL, FL_Control_L},
|
||||
{VK_MENU, FL_Alt_L},
|
||||
{VK_PAUSE, FL_Pause},
|
||||
{VK_CAPITAL, FL_Caps_Lock},
|
||||
{VK_ESCAPE, FL_Escape},
|
||||
{VK_SPACE, ' '},
|
||||
{VK_PRIOR, FL_KP+'9', FL_Page_Up},
|
||||
{VK_NEXT, FL_KP+'3', FL_Page_Down},
|
||||
{VK_END, FL_KP+'1', FL_End},
|
||||
{VK_HOME, FL_KP+'7', FL_Home},
|
||||
{VK_LEFT, FL_KP+'4', FL_Left},
|
||||
{VK_UP, FL_KP+'8', FL_Up},
|
||||
{VK_RIGHT, FL_KP+'6', FL_Right},
|
||||
{VK_DOWN, FL_KP+'2', FL_Down},
|
||||
{VK_PRIOR, FL_KP+'9'},
|
||||
{VK_NEXT, FL_KP+'3'},
|
||||
{VK_END, FL_KP+'1'},
|
||||
{VK_HOME, FL_KP+'7'},
|
||||
{VK_LEFT, FL_KP+'4'},
|
||||
{VK_UP, FL_KP+'8'},
|
||||
{VK_RIGHT, FL_KP+'6'},
|
||||
{VK_DOWN, FL_KP+'2'},
|
||||
{VK_SNAPSHOT, FL_Print}, // does not work on NT
|
||||
{VK_INSERT, FL_KP+'0', FL_Insert},
|
||||
{VK_DELETE, FL_KP+'.', FL_Delete},
|
||||
{VK_INSERT, FL_KP+'0'},
|
||||
{VK_DELETE, FL_KP+'.'},
|
||||
{VK_LWIN, FL_Meta_L},
|
||||
{VK_RWIN, FL_Meta_R},
|
||||
{VK_APPS, FL_Menu},
|
||||
@ -208,19 +208,35 @@ static const struct {unsigned short vk, fltk, extended;} vktab[] = {
|
||||
};
|
||||
static int ms2fltk(int vk, int extended) {
|
||||
static unsigned short vklut[256];
|
||||
static unsigned short extendedlut[256];
|
||||
if (!vklut[1]) { // init the table
|
||||
unsigned int i;
|
||||
for (i = 0; i < 256; i++) vklut[i] = tolower(i);
|
||||
for (i=VK_F1; i<=VK_F16; i++) vklut[i] = i+(FL_F-(VK_F1-1));
|
||||
for (i=VK_NUMPAD0; i<=VK_NUMPAD9; i++) vklut[i] = i+(FL_KP+'0'-VK_NUMPAD0);
|
||||
for (i = 0; i < sizeof(vktab)/sizeof(*vktab); i++) {
|
||||
for (i = 0; i < sizeof(vktab)/sizeof(*vktab); i++)
|
||||
vklut[vktab[i].vk] = vktab[i].fltk;
|
||||
extendedlut[vktab[i].vk] = vktab[i].extended;
|
||||
}
|
||||
for (i = 0; i < 256; i++) if (!extendedlut[i]) extendedlut[i] = vklut[i];
|
||||
if (extended)
|
||||
{
|
||||
//this is lame, have to check the vk code to make it faster
|
||||
switch (vk) {
|
||||
case VK_INSERT: return FL_Insert;
|
||||
case VK_DELETE: return FL_Delete;
|
||||
case VK_END: return FL_End;
|
||||
case VK_DOWN: return FL_Down;
|
||||
case VK_NEXT: return FL_Page_Down;
|
||||
case VK_LEFT: return FL_Left;
|
||||
case VK_RIGHT: return FL_Right;
|
||||
case VK_HOME: return FL_Home;
|
||||
case VK_UP: return FL_Up;
|
||||
case VK_PRIOR: return FL_Page_Up;
|
||||
case VK_SHIFT: return FL_Shift_R;
|
||||
case VK_CONTROL : return FL_Control_R;
|
||||
case VK_MENU: return FL_Alt_R;
|
||||
case VK_RETURN: return FL_KP_Enter;
|
||||
}
|
||||
return extended ? extendedlut[vk] : vklut[vk];
|
||||
}
|
||||
return vklut[vk];
|
||||
}
|
||||
|
||||
#if USE_COLORMAP
|
||||
@ -317,10 +333,19 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||
goto STUPID_MICROSOFT;
|
||||
}
|
||||
// otherwise use it as a 0-character key...
|
||||
// otherwise use it as a 0-character key...
|
||||
case WM_DEADCHAR:
|
||||
case WM_SYSDEADCHAR:
|
||||
buffer[0] = 0;
|
||||
Fl::e_text = buffer;
|
||||
Fl::e_length = 0;
|
||||
goto GETSTATE;
|
||||
case WM_CHAR:
|
||||
case WM_SYSCHAR:
|
||||
buffer[0] = char(wParam);
|
||||
Fl::e_text = buffer;
|
||||
Fl::e_length = 1;
|
||||
GETSTATE:
|
||||
{ulong state = Fl::e_state & 0xff000000; // keep the mouse button state
|
||||
// if GetKeyState is expensive we might want to comment some of these out:
|
||||
if (GetKeyState(VK_SHIFT)&~1) state |= FL_SHIFT;
|
||||
@ -335,17 +360,6 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||
if (GetKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK;
|
||||
Fl::e_state = state;}
|
||||
if (lParam & (1<<31)) goto DEFAULT; // ignore up events after fixing shift
|
||||
if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) {
|
||||
buffer[0] = char(wParam);
|
||||
Fl::e_length = 1;
|
||||
} else if (Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last) {
|
||||
buffer[0] = Fl::e_keysym-FL_KP;
|
||||
Fl::e_length = 1;
|
||||
} else {
|
||||
buffer[0] = 0;
|
||||
Fl::e_length = 0;
|
||||
}
|
||||
Fl::e_text = buffer;
|
||||
// for (int i = lParam&0xff; i--;)
|
||||
while (window->parent()) window = window->window();
|
||||
if (Fl::handle(FL_KEYBOARD,window)) return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user