# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 994426377 0 # Node ID 26e2130135b9e1791a890ad7a8971f626f176c8d # Parent cfab3266106ffbf995172ea7e04500d1e12e3b1d Many Win32 and GTK fixes. diff -r cfab3266106f -r 26e2130135b9 dw.def --- a/dw.def Fri Jul 06 13:32:00 2001 +0000 +++ b/dw.def Fri Jul 06 13:32:57 2001 +0000 @@ -95,6 +95,8 @@ dw_mle_set @178 dw_mle_set_visible @179 dw_mle_search @180 + dw_mle_set_editable @181 + dw_mle_set_word_wrap @182 dw_spinbutton_new @190 dw_spinbutton_set_pos @191 diff -r cfab3266106f -r 26e2130135b9 dww.def --- a/dww.def Fri Jul 06 13:32:00 2001 +0000 +++ b/dww.def Fri Jul 06 13:32:57 2001 +0000 @@ -92,6 +92,8 @@ dw_mle_set @178 dw_mle_set_visible @179 dw_mle_search @180 + dw_mle_set_editable @181 + dw_mle_set_word_wrap @182 dw_spinbutton_new @190 dw_spinbutton_set_pos @191 diff -r cfab3266106f -r 26e2130135b9 gtk/dw.c --- a/gtk/dw.c Fri Jul 06 13:32:00 2001 +0000 +++ b/gtk/dw.c Fri Jul 06 13:32:57 2001 +0000 @@ -612,6 +612,9 @@ { int _locked_by_me = FALSE; + if(!handle) + return 0; + DW_MUTEX_LOCK; gtk_widget_show(handle); DW_MUTEX_UNLOCK; @@ -627,6 +630,9 @@ { int _locked_by_me = FALSE; + if(!handle) + return 0; + DW_MUTEX_LOCK; gtk_widget_hide(handle); DW_MUTEX_UNLOCK; @@ -642,6 +648,9 @@ { int _locked_by_me = FALSE; + if(!handle) + return 0; + DW_MUTEX_LOCK; gtk_widget_destroy(handle); DW_MUTEX_UNLOCK; @@ -723,15 +732,15 @@ gdk_color_alloc(_dw_cmap, &backcolor); style = gtk_widget_get_style(handle); - style->fg[0] = forecolor; - style->bg[0] = backcolor; + style->fg[1] = style->fg[0] = forecolor; + style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor; gtk_widget_set_style(handle, style); } else { style = gtk_widget_get_style(handle); - style->fg[0] = _colors[fore]; - style->bg[0] = _colors[back]; + style->fg[1] = style->fg[0] = _colors[fore]; + style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back]; gtk_widget_set_style(handle, style); } @@ -757,6 +766,13 @@ if(tmp) handle2 = tmp; } + else if(GTK_IS_BOX(handle)) + { + GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle"); + if(tmp) + handle2 = tmp; + } + gtk_object_set_data(GTK_OBJECT(handle2), "fore", (gpointer)fore); gtk_object_set_data(GTK_OBJECT(handle2), "back", (gpointer)back); @@ -1046,7 +1062,7 @@ { GtkWidget *tmphandle; char accel, *tempbuf = malloc(strlen(title)+1); - int _locked_by_me = FALSE; + int _locked_by_me = FALSE, submenucount; guint tmp_key; GtkAccelGroup *accel_group; @@ -1060,6 +1076,7 @@ accel = _removetilde(tempbuf, title); accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu->menu), "accel"); + submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu->menu), "submenucount"); if(strlen(tempbuf) == 0) tmphandle=gtk_menu_item_new(); @@ -1096,7 +1113,15 @@ gtk_widget_show(tmphandle); if(submenu) + { + char tempbuf[100]; + + sprintf(tempbuf, "submenu%d", submenucount); + submenucount++; gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu->menu); + gtk_object_set_data(GTK_OBJECT(menu->menu), tempbuf, (gpointer)submenu->menu); + gtk_object_set_data(GTK_OBJECT(menu->menu), "submenucount", (gpointer)submenucount); + } if(GTK_IS_MENU_BAR(menu->menu)) gtk_menu_bar_append(GTK_MENU_BAR(menu->menu), tmphandle); @@ -1109,6 +1134,30 @@ return tmphandle; } +GtkWidget *_find_submenu_id(GtkWidget *start, char *name) +{ + GtkWidget *tmp; + int z, submenucount = (int)gtk_object_get_data(GTK_OBJECT(start), "submenucount"); + + if((tmp = gtk_object_get_data(GTK_OBJECT(start), name))) + return tmp; + + for(z=0;zmenu), numbuf); + sprintf(numbuf, "%lu", id); + tmphandle = _find_submenu_id(menu->menu, numbuf); if(tmphandle) { @@ -3222,7 +3271,7 @@ int _locked_by_me = FALSE; gint gx, gy, gwidth, gheight, gdepth; - if(handle->window) + if(handle && handle->window) { DW_MUTEX_LOCK; gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth); diff -r cfab3266106f -r 26e2130135b9 os2/dw.c --- a/os2/dw.c Fri Jul 06 13:32:00 2001 +0000 +++ b/os2/dw.c Fri Jul 06 13:32:57 2001 +0000 @@ -2705,7 +2705,7 @@ * id: Menuitem id. * check: TRUE for checked FALSE for not checked. */ -void dw_menu_item_set_check(HMENUI menux, int id, int check) +void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) { HWND menu; diff -r cfab3266106f -r 26e2130135b9 win/dw.c --- a/win/dw.c Fri Jul 06 13:32:00 2001 +0000 +++ b/win/dw.c Fri Jul 06 13:32:57 2001 +0000 @@ -16,6 +16,12 @@ #include #include "dw.h" +/* Get around apparent bugs in the + * Microsoft runtime when in the debugger. + * You can set this value to 0 when releasing. + */ +#define DEBUG_MALLOC 100 + /* this is the callback handle for the window procedure */ /* make sure you always match the calling convention! */ int (*filterfunc)(HWND, UINT, WPARAM, LPARAM) = 0L; @@ -39,10 +45,11 @@ HICON lookup[200]; HIMAGELIST hSmall, hLarge; -COLORREF _foreground = RGB(127, 127, 127); -COLORREF _background = 0; -HPEN _hPen; -HBRUSH _hBrush; +#define THREAD_LIMIT 128 +COLORREF _foreground[THREAD_LIMIT]; +COLORREF _background[THREAD_LIMIT]; +HPEN _hPen[THREAD_LIMIT]; +HBRUSH _hBrush[THREAD_LIMIT]; #ifdef DWDEBUG FILE *f; @@ -1752,62 +1759,76 @@ { switch (msg) { + case WM_SETTEXT: + { + /* Make sure the control redraws when there is a text change */ + int ret = (int)DefWindowProc(hwnd, msg, mp1, mp2); + + InvalidateRgn(hwnd, NULL, TRUE); + return ret; + } case WM_PAINT: { HDC hdcPaint; PAINTSTRUCT ps; - RECT rcPaint; - HBRUSH hBrush; - HPEN hPen; + RECT rc; HFONT hFont; + HBRUSH oldBrush; + HPEN oldPen; + unsigned long cx, cy; + int threadid = dw_thread_id(); char tempbuf[1024] = ""; + if(threadid < 0 || threadid >= THREAD_LIMIT) + threadid = 0; + hdcPaint = BeginPaint(hwnd, &ps); - GetWindowRect(hwnd, &rcPaint); - - dw_color_foreground_set(DW_RGB(_red[DW_CLR_PALEGRAY], - _green[DW_CLR_PALEGRAY], - _blue[DW_CLR_PALEGRAY])); - - dw_draw_rect(hwnd, 0, TRUE, 1, 1, rcPaint.right - rcPaint.left - 2, rcPaint.bottom - rcPaint.top - 2); - - dw_color_foreground_set(DW_RGB(_red[DW_CLR_DARKGRAY], - _green[DW_CLR_DARKGRAY], - _blue[DW_CLR_DARKGRAY])); - - dw_draw_line(hwnd, 0, 0, 0, rcPaint.right - rcPaint.left, 0); - dw_draw_line(hwnd, 0, 0, 0, 0, rcPaint.bottom - rcPaint.top); - - dw_color_foreground_set(DW_RGB(_red[DW_CLR_WHITE], - _green[DW_CLR_WHITE], - _blue[DW_CLR_WHITE])); - - dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, rcPaint.right - rcPaint.left - 1, 0); - dw_draw_line(hwnd, 0, rcPaint.right - rcPaint.left - 1, rcPaint.bottom - rcPaint.top - 1, 0, rcPaint.bottom - rcPaint.top - 1); - - rcPaint.left += 3; - rcPaint.top++; - rcPaint.bottom--; - rcPaint.right--; + EndPaint(hwnd, &ps); + + hdcPaint = GetDC(hwnd); + + oldBrush = _hBrush[threadid]; + oldPen = _hPen[threadid]; + + dw_window_get_pos_size(hwnd, NULL, NULL, &cx, &cy); + + _hBrush[threadid] = GetStockObject(LTGRAY_BRUSH); + + dw_draw_rect(hwnd, 0, TRUE, 0, 0, cx, cy); + + _hPen[threadid] = CreatePen(PS_SOLID, 1, RGB(_red[DW_CLR_DARKGRAY], + _green[DW_CLR_DARKGRAY], + _blue[DW_CLR_DARKGRAY])); + + dw_draw_line(hwnd, 0, 0, 0, cx, 0); + dw_draw_line(hwnd, 0, 0, 0, 0, cy); + + DeleteObject(_hPen[threadid]); + + _hPen[threadid] = GetStockObject(WHITE_PEN); + + dw_draw_line(hwnd, 0, cx - 1, cy - 1, cx - 1, 0); + dw_draw_line(hwnd, 0, cx - 1, cy - 1, 0, cy - 1); + + rc.left = 3; + rc.top = 1; + rc.bottom = cy - 1; + rc.right = cx - 1; GetWindowText(hwnd, tempbuf, 1024); - dw_color_foreground_set(DW_RGB(_red[DW_CLR_BLACK], - _green[DW_CLR_BLACK], - _blue[DW_CLR_BLACK])); - - hBrush = (HBRUSH)SelectObject(hdcPaint, _hBrush); - hPen = (HPEN)SelectObject(hdcPaint, _hPen); hFont = (HFONT)SelectObject(hdcPaint, GetStockObject(DEFAULT_GUI_FONT)); - ExtTextOut(hdcPaint, rcPaint.left, rcPaint.top, ETO_CLIPPED, - &rcPaint, tempbuf, strlen(tempbuf), NULL); - - SelectObject(hdcPaint, hBrush); - SelectObject(hdcPaint, hPen); + SetTextColor(hdcPaint, RGB(0,0,0)); + SetBkMode(hdcPaint, TRANSPARENT); + + ExtTextOut(hdcPaint, 3, 1, ETO_CLIPPED, &rc, tempbuf, strlen(tempbuf), NULL); + SelectObject(hdcPaint, hFont); - EndPaint(hwnd, &ps); + _hBrush[threadid] = oldBrush; + _hPen[threadid] = oldPen; + ReleaseDC(hwnd, hdcPaint); } return FALSE; } @@ -1970,6 +1991,7 @@ size.cy + 2, SWP_NOACTIVATE | SWP_SHOWWINDOW); + ReleaseDC(hwndBubble, hdc); } } } @@ -2117,8 +2139,13 @@ /* We need the version to check capability like up-down controls */ dwVersion = GetVersion(); - _hPen = CreatePen(PS_SOLID, 1, _foreground); - _hBrush = CreateSolidBrush(_foreground); + for(z=0;zpad = 0; newbox->type = BOXVERT; newbox->count = 0; + if(hwndOwner) + flStyleEx |= WS_EX_MDICHILD; + if(!(flStyle & WS_CAPTION)) flStyle |= WS_POPUPWINDOW; + if(flStyle & DW_FCF_TASKLIST) { - ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST; - hwndframe = CreateWindow(ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); + ULONG newflags = (flStyle | WS_CLIPCHILDREN) & ~DW_FCF_TASKLIST; + + hwndframe = CreateWindowEx(flStyleEx, ClassName, title, newflags, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); } else - hwndframe = CreateWindowEx(WS_EX_TOOLWINDOW, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, + { + flStyleEx |= WS_EX_TOOLWINDOW; + + hwndframe = CreateWindowEx(flStyleEx, ClassName, title, flStyle | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, NULL, NULL, NULL); + } SetWindowLong(hwndframe, GWL_USERDATA, (ULONG)newbox); + if(hwndOwner) + SetParent(hwndframe, hwndOwner); + return hwndframe; } @@ -2490,7 +2530,7 @@ */ HWND dw_box_new(int type, int pad) { - Box *newbox = malloc(sizeof(Box)); + Box *newbox = malloc(sizeof(Box)+DEBUG_MALLOC); HWND hwndframe; newbox->pad = pad; @@ -2711,7 +2751,7 @@ * id: Menuitem id. * check: TRUE for checked FALSE for not checked. */ -void dw_menu_item_set_check(HMENUI menux, int id, int check) +void dw_menu_item_set_check(HMENUI menux, unsigned long id, int check) { MENUITEMINFO mii; HMENU menu; @@ -3301,7 +3341,7 @@ Item *tmpitem, *thisitem = thisbox->items; char tmpbuf[100]; - tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); + tmpitem = malloc(sizeof(Item)*(thisbox->count+1)+DEBUG_MALLOC); for(z=0;zcount;z++) { @@ -4384,7 +4424,7 @@ lvi.cchTextMax = strlen(filename); lvi.iImage = _lookup_icon(handle, (HICON)icon); - ListView_InsertItem(handle, &lvi); + ListView_SetItem(handle, &lvi); } /* @@ -4615,11 +4655,16 @@ */ void dw_color_foreground_set(unsigned long value) { - DeleteObject(_hPen); - DeleteObject(_hBrush); - _foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); - _hPen = CreatePen(PS_SOLID, 1, _foreground); - _hBrush = CreateSolidBrush(_foreground); + int threadid = dw_thread_id(); + + if(threadid < 0 || threadid >= THREAD_LIMIT) + threadid = 0; + + DeleteObject(_hPen[threadid]); + DeleteObject(_hBrush[threadid]); + _foreground[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); + _hPen[threadid] = CreatePen(PS_SOLID, 1, _foreground[threadid]); + _hBrush[threadid] = CreateSolidBrush(_foreground[threadid]); } /* Sets the current background drawing color. @@ -4630,8 +4675,12 @@ */ void dw_color_background_set(unsigned long value) { - - _background = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); + int threadid = dw_thread_id(); + + if(threadid < 0 || threadid >= THREAD_LIMIT) + threadid = 0; + + _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); } /* Draw a point on a window (preferably a render window). @@ -4644,6 +4693,10 @@ void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) { HDC hdcPaint; + int threadid = dw_thread_id(); + + if(threadid < 0 || threadid >= THREAD_LIMIT) + threadid = 0; if(handle) hdcPaint = GetDC(handle); @@ -4652,7 +4705,7 @@ else return; - SetPixel(hdcPaint, x, y, _foreground); + SetPixel(hdcPaint, x, y, _foreground[threadid]); if(!pixmap) ReleaseDC(handle, hdcPaint); } @@ -4670,6 +4723,10 @@ { HDC hdcPaint; HPEN oldPen; + int threadid = dw_thread_id(); + + if(threadid < 0 || threadid >= THREAD_LIMIT) + threadid = 0; if(handle) hdcPaint = GetDC(handle); @@ -4678,14 +4735,14 @@ else return; - oldPen = SelectObject(hdcPaint, _hPen); + oldPen = SelectObject(hdcPaint, _hPen[threadid]); MoveToEx(hdcPaint, x1, y1, NULL); LineTo(hdcPaint, x2, y2); SelectObject(hdcPaint, oldPen); /* For some reason Win98 (at least) fails * to draw the last pixel. So I do it myself. */ - SetPixel(hdcPaint, x2, y2, _foreground); + SetPixel(hdcPaint, x2, y2, _foreground[threadid]); if(!pixmap) ReleaseDC(handle, hdcPaint); } @@ -4704,6 +4761,10 @@ HDC hdcPaint; HPEN oldPen; HBRUSH oldBrush; + int threadid = dw_thread_id(); + + if(threadid < 0 || threadid >= THREAD_LIMIT) + threadid = 0; if(handle) hdcPaint = GetDC(handle); @@ -4712,8 +4773,8 @@ else return; - oldPen = SelectObject(hdcPaint, _hPen); - oldBrush = SelectObject(hdcPaint, _hBrush); + oldPen = SelectObject(hdcPaint, _hPen[threadid]); + oldBrush = SelectObject(hdcPaint, _hBrush[threadid]); Rectangle(hdcPaint, x, y, x + width, y + height); SelectObject(hdcPaint, oldPen); SelectObject(hdcPaint, oldBrush); @@ -4734,6 +4795,10 @@ HDC hdc; int size = 9, z, mustdelete = 0; HFONT hFont, oldFont; + int threadid = dw_thread_id(); + + if(threadid < 0 || threadid >= THREAD_LIMIT) + threadid = 0; if(handle) { @@ -4764,7 +4829,7 @@ } } oldFont = SelectObject(hdc, hFont); - SetTextColor(hdc, _foreground); + SetTextColor(hdc, _foreground[threadid]); SetBkMode(hdc, TRANSPARENT); TextOut(hdc, x, y, text, strlen(text)); SelectObject(hdc, oldFont);