Remove compile-time dependency on Imm32.dll on Win32. I have no MSWindows machine here, so this code is likely to contain one or more typos... . When working, this will take the burdon of linking to imm32 away, so that existing makefiles will need no changes.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6217 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2008-09-11 11:14:06 +00:00
parent cf61ea83a4
commit 483dab9e92
2 changed files with 35 additions and 79 deletions

View File

@ -107,6 +107,36 @@ static HMODULE get_wsock_mod() {
return s_wsock_mod;
}
/*
* Dynamic linking of imm32.dll
* This library is only needed for a hand full (four ATM) functions relating to
* international text rendering and locales. Dynamically loading reduces initial
* size and link dependencies.
*/
static HMODULE s_imm_module = 0;
typedef HIMC (WINAPI* flTypeImmGetContext)(HWND);
static flTypeImmGetContext flImmGetContext = 0;
typedef BOOL (WINAPI* flTypeImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
static flTypeImmSetCompositionWindow flImmSetCompositionWindow = 0;
typedef BOOL (WINAPI* flTypeImmReleaseContext)(HWND, HIMC);
static flTypeImmReleaseContext flImmReleaseContext = 0;
typedef BOOL (WINAPI* flTypeImmIsIME)(HKL);
static flTypeImmIsIME flImmIsIME = 0;
static HMODULE get_imm_module() {
if (!s_imm_module) {
s_imm_module = LoadLibrary("IMM32.DLL");
if (!s_imm_module)
Fl::fatal("FLTK Lib Error: IMM32.DLL file not found!\n\n"
"Please check your input method manager library accessibility.");
flImmGetContext = (flTypeImmGetContext)GetProcAddress(s_imm_module, "ImmGetContext");
flImmSetCompositionWindow = (flTypeImmSetCompositionWindow)GetProcAddress(s_imm_module, "ImmSetCompositionWindow");
flImmReleaseContext = (flTypeImmReleaseContext)GetProcAddress(s_imm_module, "ImmReleaseContext");
flImmIsIME = (flTypeImmIsIME)GetProcAddress(s_imm_module, "ImmIsIME");
}
return s_imm_module;
}
//
// USE_TRACK_MOUSE - define it if you have TrackMouseEvent()...
//
@ -191,7 +221,8 @@ void fl_reset_spot()
void fl_set_spot(int font, int size, int x, int y, int w, int h)
{
HIMC himc = ImmGetContext(fl_msg.hwnd);
get_imm_module();
HIMC himc = flImmGetContext(fl_msg.hwnd);
if (himc) {
Fl_Window* w = fl_find(fl_msg.hwnd);
@ -202,9 +233,9 @@ void fl_set_spot(int font, int size, int x, int y, int w, int h)
cfs.ptCurrentPos.x = x;
cfs.ptCurrentPos.y = y - w->labelsize();
MapWindowPoints(fl_msg.hwnd, fl_xid(w), &cfs.ptCurrentPos, 1);
ImmSetCompositionWindow(himc, &cfs);
flImmSetCompositionWindow(himc, &cfs);
ImmReleaseContext(fl_msg.hwnd, himc);
flImmReleaseContext(fl_msg.hwnd, himc);
}
}
@ -558,7 +589,7 @@ void fl_get_codepage()
fl_codepage = ccp;
if (fl_aimm) {
fl_aimm->GetCodePageA(GetKeyboardLayout(0), &fl_codepage);
} else if (ImmIsIME(hkl)) {
} else if (get_imm_module() && flImmIsIME(hkl)) {
fl_is_ime = 1;
}
}

View File

@ -1,75 +0,0 @@
/* Drag and Drop test demo. */
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
static Fl_Window *win_a;
static Fl_Window *win_b;
class Sender : public Fl_Box {
public:
Sender(int x,int y,int w,int h) : Fl_Box(x,y,w,h) { }
int handle(int event) {
int ret = Fl_Box::handle(event);
switch ( event ) {
case FL_PUSH:
Fl::copy("message",7,0);
Fl::dnd();
return(1);
}
return(ret);
}
};
class Receiver : public Fl_Box {
public:
Receiver(int x,int y,int w,int h) : Fl_Box(x,y,w,h) { }
int handle(int event) {
int ret = Fl_Box::handle(event);
switch ( event ) {
case FL_DND_ENTER:
case FL_DND_DRAG:
case FL_DND_RELEASE:
return(1);
case FL_PASTE:
label(Fl::event_text());
fprintf(stderr, "PASTE: %s\n", Fl::event_text());
fflush(stderr);
return(1);
}
return(ret);
}
};
//
// Demonstrate DND (drag+drop) from red sender to green receiver
//
static Sender *Tx;
static Receiver *Rx;
int main(int argc, char **argv) {
win_a = new Fl_Window(40, 40, 200,100);
win_a->begin();
Tx = new Sender(5,5,90,90);
Tx->box(FL_UP_BOX);
Tx->label("Drag from here");
Tx->align(FL_ALIGN_WRAP);
Tx->color(FL_RED);
win_a->end();
win_a->show(argc, argv);
win_b = new Fl_Window (350, 40, 200,100,"Receiver");
win_b->begin();
Rx = new Receiver(105,5,90,90);
Rx->box(FL_FLAT_BOX);
Rx->label("to here");
Rx->color(FL_GREEN);
win_b->end();
win_b->show();
return Fl::run();
}
/* End of File */