# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1003789978 0 # Node ID 88c9c7410c22a70e9968431dc9b6bedd15facf3f # Parent 3aa9ef0b399617feaebe5759341031ae2c201929 Lots of fixes and new functions on all platforms. diff -r 3aa9ef0b3996 -r 88c9c7410c22 dw.def --- a/dw.def Fri Oct 19 14:16:50 2001 +0000 +++ b/dw.def Mon Oct 22 22:32:58 2001 +0000 @@ -57,6 +57,9 @@ dw_window_minimize @73 dw_window_pointer @74 dw_window_default @75 + dw_window_raise @76 + dw_window_lower @77 + dw_window_click_default @78 dw_bitmap_new @80 diff -r 3aa9ef0b3996 -r 88c9c7410c22 dw.h --- a/dw.h Fri Oct 19 14:16:50 2001 +0000 +++ b/dw.h Mon Oct 22 22:32:58 2001 +0000 @@ -112,6 +112,11 @@ #define DW_POINTER_ARROW SPTR_ARROW #define DW_POINTER_CLOCK SPTR_WAIT +typedef struct _window_data { + PFNWP oldproc; + HWND clickdefault; +} WindowData; + typedef struct _hpixmap { unsigned long width, height; HDC hdc; @@ -257,6 +262,7 @@ int back; HWND combo, buddy; int user; + HWND clickdefault; HBRUSH hbrush; char fontname[128]; WNDPROC pOldProc; @@ -314,6 +320,8 @@ ColorInfo cinfo; #elif defined(__OS2__) || defined(__EMX__) PFNWP oldproc; + HWND hwndtitle; + int titlebar; #endif /* Number of items in the box */ int count; @@ -583,6 +591,8 @@ int dw_window_show(HWND handle); int dw_window_hide(HWND handle); int dw_window_minimize(HWND handle); +int dw_window_raise(HWND handle); +int dw_window_lower(HWND handle); int dw_window_destroy(HWND handle); int dw_window_set_font(HWND handle, char *fontname); int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back); @@ -635,6 +645,7 @@ void dw_window_reparent(HWND handle, HWND newparent); void dw_window_pointer(HWND handle, int pointertype); void dw_window_default(HWND window, HWND defaultitem); +void dw_window_click_default(HWND window, HWND next); unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint); void dw_mle_export(HWND handle, char *buffer, int startpoint, int length); void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines); diff -r 3aa9ef0b3996 -r 88c9c7410c22 dww.def --- a/dww.def Fri Oct 19 14:16:50 2001 +0000 +++ b/dww.def Mon Oct 22 22:32:58 2001 +0000 @@ -54,6 +54,9 @@ dw_window_minimize @73 dw_window_pointer @74 dw_window_default @75 + dw_window_raise @76 + dw_window_lower @77 + dw_window_click_default @78 dw_bitmap_new @80 diff -r 3aa9ef0b3996 -r 88c9c7410c22 gtk/dw.c --- a/gtk/dw.c Fri Oct 19 14:16:50 2001 +0000 +++ b/gtk/dw.c Mon Oct 22 22:32:58 2001 +0000 @@ -16,6 +16,7 @@ #include #include #include "config.h" +#include #ifdef USE_IMLIB #include #endif @@ -420,6 +421,23 @@ } } +gint _default_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + GtkWidget *next = (GtkWidget *)data; + + if(next) + { + if(event->keyval == GDK_Return) + { + if(GTK_IS_BUTTON(next)) + gtk_signal_emit_by_name(GTK_OBJECT(next), "clicked"); + else + gtk_widget_grab_focus(next); + } + } + return TRUE; +} + GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle) { char *data = NULL; @@ -629,6 +647,17 @@ } +void _dw_ok_func(HWND window, void *data) +{ + DWDialog *dwwait = (DWDialog *)data; + + if(!dwwait) + return; + + dw_window_destroy((HWND)dwwait->data); + dw_dialog_dismiss((DWDialog *)data, (void *)0); +} + /* * Displays a Message Box with given text and title.. * Parameters: @@ -638,37 +667,44 @@ */ int dw_messagebox(char *title, char *format, ...) { + HWND entrywindow, mainbox, okbutton, buttonbox, stext; + ULONG flStyle = DW_FCF_TITLEBAR | DW_FCF_SHELLPOSITION | DW_FCF_DLGBORDER; + DWDialog *dwwait; va_list args; char outbuf[256]; - GtkWidget *dialog, - *button, - *label; - int _locked_by_me = FALSE; - - DW_MUTEX_LOCK; + va_start(args, format); vsprintf(outbuf, format, args); va_end(args); - dialog = gtk_dialog_new(); - - gtk_window_set_title(GTK_WINDOW(dialog), title); - - button = gtk_button_new_with_label("Ok"); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(_delete2), (gpointer)dialog); - gtk_signal_connect(GTK_OBJECT(dialog), "delete_event", GTK_SIGNAL_FUNC(_delete), (gpointer)dialog); - - label = gtk_label_new(outbuf); - gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 20); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 0); - gtk_widget_show(label); - - gtk_widget_show(dialog); - - DW_MUTEX_UNLOCK; + entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle); + mainbox = dw_box_new(BOXVERT, 10); + dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0); + + /* Archive Name */ + stext = dw_text_new(outbuf, 0); + dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK); + + dw_box_pack_start(mainbox, stext, 205, 50, TRUE, TRUE, 2); + + /* Buttons */ + buttonbox = dw_box_new(BOXHORZ, 10); + + dw_box_pack_start(mainbox, buttonbox, 0, 0, TRUE, FALSE, 0); + + okbutton = dw_button_new("Ok", 1001L); + + dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2); + + dwwait = dw_dialog_new((void *)entrywindow); + + dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait); + + dw_window_set_usize(entrywindow, 220, 110); + + dw_window_show(entrywindow); + + dw_dialog_wait(dwwait); return strlen(outbuf); } @@ -717,28 +753,29 @@ /* Archive Name */ stext = dw_text_new(text, 0); - - dw_box_pack_start(mainbox, stext, 130, 20, TRUE, TRUE, 2); + dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK); + + dw_box_pack_start(mainbox, stext, 205, 50, TRUE, TRUE, 2); /* Buttons */ buttonbox = dw_box_new(BOXHORZ, 10); - dw_box_pack_start(mainbox, buttonbox, 0, 0, TRUE, TRUE, 0); + dw_box_pack_start(mainbox, buttonbox, 0, 0, TRUE, FALSE, 0); yesbutton = dw_button_new("Yes", 1001L); - dw_box_pack_start(buttonbox, yesbutton, 130, 30, TRUE, TRUE, 2); + dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 2); nobutton = dw_button_new("No", 1002L); - dw_box_pack_start(buttonbox, nobutton, 130, 30, TRUE, TRUE, 2); + dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2); dwwait = dw_dialog_new((void *)entrywindow); dw_signal_connect(yesbutton, "clicked", DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait); dw_signal_connect(nobutton, "clicked", DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait); - dw_window_set_usize(entrywindow, 340, 150); + dw_window_set_usize(entrywindow, 220, 110); dw_window_show(entrywindow); @@ -766,6 +803,42 @@ } /* + * Makes the window topmost. + * Parameters: + * handle: The window handle to make topmost. + */ +int dw_window_raise(HWND handle) +{ + int _locked_by_me = FALSE; + + if(!handle) + return 0; + + DW_MUTEX_LOCK; + gdk_window_raise(GTK_WIDGET(handle)->window); + DW_MUTEX_UNLOCK; + return 0; +} + +/* + * Makes the window bottommost. + * Parameters: + * handle: The window handle to make bottommost. + */ +int dw_window_lower(HWND handle) +{ + int _locked_by_me = FALSE; + + if(!handle) + return 0; + + DW_MUTEX_LOCK; + gdk_window_lower(GTK_WIDGET(handle)->window); + DW_MUTEX_UNLOCK; + return 0; +} + +/* * Makes the window visible. * Parameters: * handle: The window handle to make visible. @@ -2111,7 +2184,7 @@ if(tmp && GTK_IS_TEXT(tmp)) { if(bytes) - *bytes = gtk_text_get_length(GTK_TEXT(tmp)); + *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1; if(lines) { gchar *text; @@ -2284,6 +2357,19 @@ if(tmp && GTK_IS_TEXT(tmp)) { + unsigned long chars; + float pos, ratio; + + dw_mle_query(handle, &chars, NULL); + + if(chars) + { + ratio = (float)point/(float)chars; + + pos = (ratio * (float)(GTK_TEXT(tmp)->vadj->upper - GTK_TEXT(tmp)->vadj->lower)) + GTK_TEXT(tmp)->vadj->lower; + + gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos); + } gtk_text_set_point(GTK_TEXT(tmp), point); } } @@ -4602,6 +4688,24 @@ } /* + * Sets window to click the default dialog item when an ENTER is pressed. + * Parameters: + * window: Window (widget) to look for the ENTER press. + * next: Window (widget) to move to next (or click) + */ +void dw_window_click_default(HWND window, HWND next) +{ + int _locked_by_me = FALSE; + + if(!window) + return; + + DW_MUTEX_LOCK; + gtk_signal_connect(GTK_OBJECT(window), "key_press_event", GTK_SIGNAL_FUNC(_default_key_press_event), next); + DW_MUTEX_UNLOCK; +} + +/* * Returns some information about the current operating environment. * Parameters: * env: Pointer to a DWEnv struct. diff -r 3aa9ef0b3996 -r 88c9c7410c22 os2/dw.c --- a/os2/dw.c Fri Oct 19 14:16:50 2001 +0000 +++ b/os2/dw.c Mon Oct 22 22:32:58 2001 +0000 @@ -1198,12 +1198,48 @@ return WinDefWindowProc(hWnd, msg, mp1, mp2); } +void _click_default(HWND handle) +{ + char tmpbuf[100]; + + WinQueryClassName(handle, 99, tmpbuf); + + /* These are the window classes which can + * obtain input focus. + */ + if(strncmp(tmpbuf, "#3", 3)==0) + { + /* Generate click on default item */ + SignalHandler *tmp = Root; + + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == WM_COMMAND) + { + int (*clickfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; + + /* Make sure it's the right window, and the right ID */ + if(tmp->window == handle) + { + clickfunc(tmp->window, tmp->data); + tmp = NULL; + } + } + if(tmp) + tmp= tmp->next; + } + } + else + WinSetFocus(HWND_DESKTOP, handle); +} + /* Originally just intended for entryfields, it now serves as a generic * procedure for handling TAB presses to change input focus on controls. */ MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); + WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER); switch(msg) { @@ -1228,13 +1264,13 @@ _shift_focus(hWnd); return FALSE; } + else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) + _click_default(blah->clickdefault); + break; } - if(blah && *blah) - { - PFNWP myfunc = *blah; - return myfunc(hWnd, msg, mp1, mp2); - } + if(blah && blah->oldproc) + return blah->oldproc(hWnd, msg, mp1, mp2); return WinDefWindowProc(hWnd, msg, mp1, mp2); } @@ -1244,7 +1280,7 @@ */ MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - PFNWP *blah = WinQueryWindowPtr(hWnd, QWP_USER); + WindowData *blah = WinQueryWindowPtr(hWnd, QWP_USER); switch(msg) { @@ -1254,6 +1290,8 @@ _shift_focus(hWnd); return FALSE; } + else if(SHORT1FROMMP(mp2) == '\r' && blah && blah->clickdefault) + _click_default(blah->clickdefault); break; case WM_BUTTON1DOWN: case WM_BUTTON2DOWN: @@ -1289,11 +1327,8 @@ } break; } - if(blah && *blah) - { - PFNWP myfunc = *blah; - return myfunc(hWnd, msg, mp1, mp2); - } + if(blah && blah->oldproc) + return blah->oldproc(hWnd, msg, mp1, mp2); return WinDefWindowProc(hWnd, msg, mp1, mp2); } @@ -2602,6 +2637,26 @@ } /* + * Makes the window topmost. + * Parameters: + * handle: The window handle to make topmost. + */ +int dw_window_raise(HWND handle) +{ + return WinSetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER); +} + +/* + * Makes the window bottommost. + * Parameters: + * handle: The window handle to make bottommost. + */ +int dw_window_lower(HWND handle) +{ + return WinSetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER); +} + +/* * Makes the window visible. * Parameters: * handle: The window handle to make visible. @@ -3322,7 +3377,8 @@ */ HWND dw_entryfield_new(char *text, ULONG id) { - PFNWP *blah = malloc(sizeof(PFNWP)); + + WindowData *blah = calloc(1, sizeof(WindowData)); HWND tmp = WinCreateWindow(HWND_OBJECT, WC_ENTRYFIELD, text, @@ -3335,7 +3391,7 @@ NULL, NULL); dw_window_set_font(tmp, DefaultFont); - *blah = WinSubclassWindow(tmp, _entryproc); + blah->oldproc = WinSubclassWindow(tmp, _entryproc); WinSetWindowPtr(tmp, QWP_USER, blah); return tmp; } @@ -3348,7 +3404,7 @@ */ HWND dw_entryfield_password_new(char *text, ULONG id) { - PFNWP *blah = malloc(sizeof(PFNWP)); + WindowData *blah = calloc(1, sizeof(WindowData)); HWND tmp = WinCreateWindow(HWND_OBJECT, WC_ENTRYFIELD, text, @@ -3361,7 +3417,7 @@ NULL, NULL); dw_window_set_font(tmp, DefaultFont); - *blah = WinSubclassWindow(tmp, _entryproc); + blah->oldproc = WinSubclassWindow(tmp, _entryproc); WinSetWindowPtr(tmp, QWP_USER, blah); return tmp; } @@ -3374,7 +3430,7 @@ */ HWND dw_combobox_new(char *text, ULONG id) { - PFNWP *blah = malloc(sizeof(PFNWP)); + WindowData *blah = calloc(1, sizeof(WindowData)); HWND tmp = WinCreateWindow(HWND_OBJECT, WC_COMBOBOX, text, @@ -3387,7 +3443,7 @@ NULL); dw_window_set_font(tmp, DefaultFont); dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); - *blah = WinSubclassWindow(tmp, _comboproc); + blah->oldproc = WinSubclassWindow(tmp, _comboproc); WinSetWindowPtr(tmp, QWP_USER, blah); return tmp; } @@ -6049,6 +6105,26 @@ } /* + * Sets window to click the default dialog item when an ENTER is pressed. + * Parameters: + * window: Window (widget) to look for the ENTER press. + * next: Window (widget) to move to next (or click) + */ +void dw_window_click_default(HWND window, HWND next) +{ + WindowData *blah = (WindowData *)WinQueryWindowPtr(window, QWP_USER); + char tmpbuf[100]; + + WinQueryClassName(window, 99, tmpbuf); + + /* These are the window classes which can + * obtain input focus. + */ + if(strncmp(tmpbuf, "#6", 3) == 0 && blah) + blah->clickdefault = next; +} + +/* * Returns some information about the current operating environment. * Parameters: * env: Pointer to a DWEnv struct. diff -r 3aa9ef0b3996 -r 88c9c7410c22 win/dw.c --- a/win/dw.c Fri Oct 19 14:16:50 2001 +0000 +++ b/win/dw.c Mon Oct 22 22:32:58 2001 +0000 @@ -1505,6 +1505,42 @@ return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2); } +void _click_default(HWND handle) +{ + char tmpbuf[100]; + + GetClassName(handle, tmpbuf, 99); + + /* These are the window classes which can + * obtain input focus. + */ + if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME))==0) + { + /* Generate click on default item */ + SignalHandler *tmp = Root; + + /* Find any callbacks for this function */ + while(tmp) + { + if(tmp->message == WM_COMMAND) + { + int (*clickfunc)(HWND, void *) = tmp->signalfunction; + + /* Make sure it's the right window, and the right ID */ + if(tmp->window == handle) + { + clickfunc(tmp->window, tmp->data); + tmp = NULL; + } + } + if(tmp) + tmp= tmp->next; + } + } + else + SetFocus(handle); +} + BOOL CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) { ColorInfo *cinfo; @@ -1534,6 +1570,13 @@ _shift_focus(hWnd); return FALSE; } + else if(LOWORD(mp1) == '\r') + { + if(cinfo->clickdefault) + _click_default(cinfo->clickdefault); + + } + /* Tell the spinner control that a keypress has * occured and to update it's internal value. */ @@ -2538,6 +2581,26 @@ } /* + * Makes the window topmost. + * Parameters: + * handle: The window handle to make topmost. + */ +int dw_window_raise(HWND handle) +{ + return SetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); +} + +/* + * Makes the window bottommost. + * Parameters: + * handle: The window handle to make bottommost. + */ +int dw_window_lower(HWND handle) +{ + return SetWindowPos(handle, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); +} + +/* * Makes the window visible. * Parameters: * handle: The window handle to make visible. @@ -3773,7 +3836,7 @@ */ void dw_window_set_pos(HWND handle, ULONG x, ULONG y) { - SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } /* @@ -3787,7 +3850,7 @@ */ void dw_window_set_pos_size(HWND handle, ULONG x, ULONG y, ULONG width, ULONG height) { - SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW); + SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); } /* @@ -5744,6 +5807,20 @@ } /* + * Sets window to click the default dialog item when an ENTER is pressed. + * Parameters: + * window: Window (widget) to look for the ENTER press. + * next: Window (widget) to move to next (or click) + */ +void dw_window_click_default(HWND window, HWND next) +{ + ColorInfo *cinfo = (ColorInfo *)GetWindowLong(window, GWL_USERDATA); + + if(cinfo) + cinfo->clickdefault = next; +} + +/* * Returns some information about the current operating environment. * Parameters: * env: Pointer to a DWEnv struct.