# HG changeset patch # User mhessling@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1090308971 0 # Node ID 828e6a66c5c50882f552e054482a1dab44cbc30f # Parent 052e9e4a59bd6bd381bf25ad5cb93705b0e00609 Add dw_listbox_list_append() diff -r 052e9e4a59bd -r 828e6a66c5c5 compat.h --- a/compat.h Tue Jul 20 07:31:53 2004 +0000 +++ b/compat.h Tue Jul 20 07:36:11 2004 +0000 @@ -94,7 +94,7 @@ #ifndef BKS_TABBEDDIALOG #define BKS_TABBEDDIALOG 0x0800 -#endif +#endif #define PIPENAME "\\socket\\" __TARGET__ "%d" #define TPIPENAME "\\socket\\" __TARGET__ "%d" @@ -123,7 +123,15 @@ #if defined(__WIN32__) || defined(WINNT) #if defined(MSVC) && !defined(API) -#define API _cdecl +# ifdef __MINGW32__ +# ifdef BUILD_DLL +# define API APIENTRY __declspec(dllexport) +# else +# define API APIENTRY __declspec(dllimport) +# endif +# else +# define API _cdecl +# endif #endif #include @@ -131,15 +139,17 @@ #include #include #include + #ifdef MSVC #include "platform/dirent.h" #else #include #include #endif + #include -#if defined(__CYGWIN32__) || defined(__MINGW32__) +#if defined(__CYGWIN32__) /*|| defined(__MINGW32__)*/ #include #endif /* __CYGWIN32__ || __MINGW32__ */ @@ -235,4 +245,10 @@ void API nice_strformat(char *dest, long double val, int dec); void API initdir(int argc, char *argv[]); int API setpath(char *path); + +#ifdef __MINGW32__ +# undef API +# define API APIENTRY #endif + +#endif diff -r 052e9e4a59bd -r 828e6a66c5c5 dw.def --- a/dw.def Tue Jul 20 07:31:53 2004 +0000 +++ b/dw.def Tue Jul 20 07:36:11 2004 +0000 @@ -88,6 +88,7 @@ dw_listbox_set_text @148 dw_listbox_selected @149 dw_listbox_selected_multi @150 + dw_listbox_list_append @151 dw_percent_new @160 dw_percent_set_pos @162 diff -r 052e9e4a59bd -r 828e6a66c5c5 dw.h --- a/dw.h Tue Jul 20 07:31:53 2004 +0000 +++ b/dw.h Tue Jul 20 07:36:11 2004 +0000 @@ -345,7 +345,15 @@ #include #if defined(MSVC) && !defined(API) -#define API _cdecl +# ifdef __MINGW32__ +# ifdef BUILD_DLL +# define API APIENTRY __declspec(dllexport) +# else +# define API APIENTRY __declspec(dllimport) +# endif +# else +# define API _cdecl +#endif #endif #define DW_DT_LEFT SS_LEFT @@ -940,6 +948,7 @@ HWND API dw_checkbox_new(char *text, unsigned long id); HWND API dw_listbox_new(unsigned long id, int multi); void API dw_listbox_append(HWND handle, char *text); +void API dw_listbox_list_append(HWND handle, char **text, int count); void API dw_listbox_clear(HWND handle); int API dw_listbox_count(HWND handle); void API dw_listbox_set_top(HWND handle, int top); diff -r 052e9e4a59bd -r 828e6a66c5c5 dww.def --- a/dww.def Tue Jul 20 07:31:53 2004 +0000 +++ b/dww.def Tue Jul 20 07:36:11 2004 +0000 @@ -85,6 +85,7 @@ dw_listbox_set_text @148 dw_listbox_selected @149 dw_listbox_selected_multi @150 + dw_listbox_list_append @151 dw_percent_new @160 dw_percent_set_pos @162 diff -r 052e9e4a59bd -r 828e6a66c5c5 gtk/dw.c --- a/gtk/dw.c Tue Jul 20 07:31:53 2004 +0000 +++ b/gtk/dw.c Tue Jul 20 07:36:11 2004 +0000 @@ -8646,6 +8646,65 @@ } /* + * Appends the specified text items to the listbox's (or combobox) entry list. + * Parameters: + * handle: Handle to the listbox to be appended to. + * text: Text strings to append into listbox. + * count: Number of text strings to append + */ +void dw_listbox_list_append(HWND handle, char **text, int count) +{ + GtkWidget *handle2 = handle; + int _locked_by_me = FALSE; + + DW_MUTEX_LOCK; + if(GTK_IS_SCROLLED_WINDOW(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)); + if(tmp) + handle2 = tmp; + } + gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1); + if(GTK_IS_LIST(handle2)) + { + GtkWidget *list_item; + GList *tmp; + char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_font"); + GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_foregdk"); + GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk"); + + list_item=gtk_list_item_new_with_label(*text); + + if(font) + _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font); + if(fore && back) + _set_color(GTK_LIST_ITEM(list_item)->item.bin.child, + DW_RGB(fore->red, fore->green, fore->blue), + DW_RGB(back->red, back->green, back->blue)); + + tmp = g_list_append(NULL, list_item); + gtk_widget_show(list_item); + gtk_list_append_items(GTK_LIST(handle2),tmp); + } + else if(GTK_IS_COMBO(handle2)) + { + GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); + char *addtext; + int i; + + for (i=0;i #include "dw.h" +/* + * MinGW (as at 3.2.3) doesn't have MIM_MENUDATA + * so #define it here + */ + +#if !defined( MIM_MENUDATA ) +# define MIM_MENUDATA 0x00000008 +#endif + HWND popup = (HWND)NULL, hwndBubble = (HWND)NULL, DW_HWND_OBJECT = (HWND)NULL; HINSTANCE DWInstance = NULL; @@ -383,7 +391,7 @@ if(array) { - int z, refid = -1; + int z; for(z=0;z<256;z++) { @@ -1473,7 +1481,7 @@ if(hWnd == tmp->window) { - int button; + int button=0; switch(origmsg) { @@ -1508,7 +1516,7 @@ if(hWnd == tmp->window) { - int button; + int button=0; switch(origmsg) { @@ -2433,7 +2441,7 @@ else val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0); - sprintf(tmpbuf, "%d", val); + sprintf(tmpbuf, "%ld", val); SetWindowText(hWnd, tmpbuf); } } @@ -2772,7 +2780,7 @@ if((hdcPaint = GetDC(hwnd)) != NULL) { - int cx, cy; + unsigned long cx, cy; HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE)); HPEN oldPen = SelectObject(hdcPaint, CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DFACE))); @@ -2873,7 +2881,6 @@ PAINTSTRUCT ps; RECT rc; unsigned long cx, cy; - int threadid = dw_thread_id(); char tempbuf[1024] = ""; ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); HFONT hfont = _acquire_font(hwnd, cinfo ? cinfo->fontname : NULL); @@ -3036,12 +3043,10 @@ if(!hwndBubble) { POINTL ptlWork = {0,0}; - ULONG ulColor = DW_CLR_YELLOW; SIZE size; HFONT hFont, oldFont = (HFONT)0; HDC hdc; RECT rect; - void *oldproc; /* Use the WS_EX_TOOLWINDOW extended style * so the window doesn't get listed in the @@ -4105,7 +4110,7 @@ if(!IS_WINNTOR95) { - sprintf(buffer, "_dw_id%d", id); + sprintf(buffer, "_dw_id%ld", id); dw_window_set_data(DW_HWND_OBJECT, buffer, (void *)mymenu); /* According to the docs this will only work on Win2k/98 and above */ @@ -4651,7 +4656,6 @@ */ HWND API dw_spinbutton_new(char *text, ULONG id) { - ULONG *data = malloc(sizeof(ULONG)); HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE, EDITCLASSNAME, text, @@ -5499,6 +5503,30 @@ } /* + * Appends the specified text items to the listbox's (or combobox) entry list. + * Parameters: + * handle: Handle to the listbox to be appended to. + * text: Text strings to append into listbox. + * count: Number of text strings to append + */ +void API dw_listbox_list_append(HWND handle, char **text, int count) +{ + char tmpbuf[100]; + int listbox_type; + int i; + + GetClassName(handle, tmpbuf, 99); + + if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) + listbox_type = CB_ADDSTRING; + else + listbox_type = LB_ADDSTRING; + + for(i=0;ibuddy) SetWindowText(cinfo->buddy, tmpbuf); @@ -6420,7 +6448,7 @@ void API dw_tree_item_delete(HWND handle, HTREEITEM item) { TVITEM tvi; - void **ptrs; + void **ptrs=NULL; if(item == TVI_ROOT || !item) return; @@ -7033,7 +7061,6 @@ if((char *)lvi.lParam == text) { - RECT viewport, item; ListView_SetItemState(handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); ListView_EnsureVisible(handle, index, TRUE); @@ -7088,8 +7115,6 @@ void API dw_container_optimize(HWND handle) { ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); - ULONG *flags; - LV_ITEM lvi; if(cinfo && cinfo->columns == 1) { @@ -7382,8 +7407,6 @@ void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) { HDC hdcPaint; - HPEN oldPen; - HBRUSH oldBrush; RECT Rect; int threadid = dw_thread_id(); @@ -7417,7 +7440,7 @@ void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) { HDC hdc; - int size = 9, z, mustdelete = 0; + int mustdelete = 0; HFONT hFont = 0, oldFont = 0; int threadid = dw_thread_id(); ColorInfo *cinfo; @@ -7535,7 +7558,6 @@ HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) { HPIXMAP pixmap; - BITMAP bm; HDC hdc; if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))