# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1037091142 0 # Node ID a07dd2e819f3d65e684c9812b5b137ff98bf9fe2 # Parent 63258b34e70dec6b581ce14c77ea10a528da36a5 Added module support. diff -r 63258b34e70d -r a07dd2e819f3 dw.def --- a/dw.def Fri Nov 08 17:38:59 2002 +0000 +++ b/dw.def Tue Nov 12 08:52:22 2002 +0000 @@ -222,3 +222,8 @@ dw_splitbar_new @410 dw_splitbar_set @411 dw_splitbar_get @412 + + dw_module_load @420 + dw_module_symbol @421 + dw_module_close @422 + diff -r 63258b34e70d -r a07dd2e819f3 dw.h --- a/dw.h Fri Nov 08 17:38:59 2002 +0000 +++ b/dw.h Tue Nov 12 08:52:22 2002 +0000 @@ -145,6 +145,8 @@ HWND menu; } *HMENUI; +typedef HMODULE HMOD; + extern HAB dwhab; extern HMQ dwhmq; #endif @@ -294,6 +296,7 @@ typedef HANDLE HMTX; typedef HANDLE HEV; +typedef HANDLE HMOD; typedef struct _container { ColorInfo cinfo; @@ -491,6 +494,7 @@ int posted; } *HEV; typedef pthread_t DWTID; +typedef void * HMOD; typedef struct _hpixmap { unsigned long width, height; @@ -781,6 +785,9 @@ void *dw_dialog_wait(DWDialog *dialog); void dw_window_set_data(HWND window, char *dataname, void *data); void *dw_window_get_data(HWND window, char *dataname); +int dw_module_load(char *name, HMOD *handle); +int dw_module_symbol(HMOD handle, char *name, void**func); +int dw_module_close(HMOD handle); #ifndef NO_SIGNALS void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data); void dw_signal_disconnect_by_window(HWND window); diff -r 63258b34e70d -r a07dd2e819f3 dww.def --- a/dww.def Fri Nov 08 17:38:59 2002 +0000 +++ b/dww.def Tue Nov 12 08:52:22 2002 +0000 @@ -219,3 +219,8 @@ dw_splitbar_new @410 dw_splitbar_set @411 dw_splitbar_get @412 + + dw_module_load @420 + dw_module_symbol @421 + dw_module_close @422 + diff -r 63258b34e70d -r a07dd2e819f3 gtk/dw.c --- a/gtk/dw.c Fri Nov 08 17:38:59 2002 +0000 +++ b/gtk/dw.c Tue Nov 12 08:52:22 2002 +0000 @@ -4965,6 +4965,86 @@ DW_MUTEX_UNLOCK; } +void _my_strlwr(char *buf) +{ + int z, len = strlen(buf); + + for(z=0;z= 'A' && buf[z] <= 'Z') + buf[z] -= 'A' - 'a'; + } +} + +/* Open a shared library and return a handle. + * Parameters: + * name: Base name of the shared library. + * handle: Pointer to a module handle, + * will be filled in with the handle. + */ +int dw_module_load(char *name, HMOD *handle) +{ + int len; + char *newname; + char errorbuf[1024]; + + + if(!handle) + return -1; + + if((len = strlen(name)) == 0) + return -1; + + /* Lenth + "lib" + ".so" + NULL */ + newname = malloc(len + 7); + + if(!newname) + return -1; + + sprintf(newname, "lib%s.so", name); + _my_strlwr(newname); + + *handle = dlopen(newname, RTLD_NOW); + if(*handle == NULL) + { + strncpy(errorbuf, dlerror(), 1024); + sprintf(newname, "lib%s.so", name); + *handle = dlopen(newname, RTLD_NOW); + } + + free(newname); + + return (NULL == *handle); +} + +/* Queries the address of a symbol within open handle. + * Parameters: + * handle: Module handle returned by dw_module_load() + * name: Name of the symbol you want the address of. + * func: A pointer to a function pointer, to obtain + * the address. + */ +int dw_module_symbol(HMOD handle, char *name, void**func) +{ + if(!func || !name) + return -1; + + if(strlen(name) == 0) + return -1; + + *func = (void*)dlsym(handle, name); + return (NULL == *func); +} + +/* Frees the shared library previously opened. + * Parameters: + * handle: Module handle returned by dw_module_load() + */ +int dw_module_close(HMOD handle) +{ + return dlclose(handle); +} + /* * Returns the handle to an unnamed mutex semaphore. */ diff -r 63258b34e70d -r a07dd2e819f3 os2/dw.c --- a/os2/dw.c Fri Nov 08 17:38:59 2002 +0000 +++ b/os2/dw.c Tue Nov 12 08:52:22 2002 +0000 @@ -6460,6 +6460,40 @@ DosBeep(freq, dur); } +/* Open a shared library and return a handle. + * Parameters: + * name: Base name of the shared library. + * handle: Pointer to a module handle, + * will be filled in with the handle. + */ +int dw_module_load(char *name, HMOD *handle) +{ + char objnamebuf[300] = ""; + + return DosLoadModule(objnamebuf, sizeof(objnamebuf), name, handle); +} + +/* Queries the address of a symbol within open handle. + * Parameters: + * handle: Module handle returned by dw_module_load() + * name: Name of the symbol you want the address of. + * func: A pointer to a function pointer, to obtain + * the address. + */ +int dw_module_symbol(HMOD handle, char *name, void**func) +{ + return DosQueryProcAddr(handle, 0, name, (PFN*)func); +} + +/* Frees the shared library previously opened. + * Parameters: + * handle: Module handle returned by dw_module_load() + */ +int dw_module_close(HMOD handle) +{ + DosFreeModule(handle); +} + /* * Returns the handle to an unnamed mutex semaphore. */ diff -r 63258b34e70d -r a07dd2e819f3 win/dw.c --- a/win/dw.c Fri Nov 08 17:38:59 2002 +0000 +++ b/win/dw.c Tue Nov 12 08:52:22 2002 +0000 @@ -2303,28 +2303,33 @@ { POINT point; RECT rect; + static POINT lastpoint; GetCursorPos(&point); GetWindowRect(hwnd, &rect); - if(PtInRect(&rect, point)) + if(memcmp(&point, &lastpoint, sizeof(POINT))) { - int width = (rect.right - rect.left); - int height = (rect.bottom - rect.top); - - if(type == BOXHORZ) + if(PtInRect(&rect, point)) { - start = point.x - rect.left; - if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH) - *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0; + int width = (rect.right - rect.left); + int height = (rect.bottom - rect.top); + + if(type == BOXHORZ) + { + start = point.x - rect.left; + if(width - SPLITBAR_WIDTH > 1 && start < width - SPLITBAR_WIDTH) + *percent = ((float)start / (float)(width - SPLITBAR_WIDTH)) * 100.0; + } + else + { + start = point.y - rect.top; + if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH) + *percent = ((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0; + } + _handle_splitbar_resize(hwnd, *percent, type, width, height); } - else - { - start = point.y - rect.top; - if(height - SPLITBAR_WIDTH > 1 && start < height - SPLITBAR_WIDTH) - *percent = ((float)start / (float)(height - SPLITBAR_WIDTH)) * 100.0; - } - _handle_splitbar_resize(hwnd, *percent, type, width, height); + memcpy(&lastpoint, &point, sizeof(POINT)); } } break; @@ -6402,6 +6407,49 @@ Beep(freq, dur); } +/* Open a shared library and return a handle. + * Parameters: + * name: Base name of the shared library. + * handle: Pointer to a module handle, + * will be filled in with the handle. + */ +int dw_module_load(char *name, HMOD *handle) +{ + if(!handle) + return -1; + + *handle = LoadLibrary(name); + return (NULL == *handle); +} + +/* Queries the address of a symbol within open handle. + * Parameters: + * handle: Module handle returned by dw_module_load() + * name: Name of the symbol you want the address of. + * func: A pointer to a function pointer, to obtain + * the address. + */ +int dw_module_symbol(HMOD handle, char *name, void**func) +{ + if(!func || !name) + return -1; + + if(0 == strlen(name)) + return -1; + + *func = (void*)GetProcAddress(handle, name); + return (NULL == *func); +} + +/* Frees the shared library previously opened. + * Parameters: + * handle: Module handle returned by dw_module_load() + */ +int dw_module_close(HMOD handle) +{ + return FreeLibrary(handle); +} + /* * Returns the handle to an unnamed mutex semaphore. */