comparison win/dw.c @ 771:5cca4ebcca9a

When destroying a spinbutton, destroy the correct window Create a default boldfont for use in groupbox titles Enable groupboxes to have their font changed Enable groupboxes to have their color changed Default font for groupbox text is default bold font Implement dw_window_get_font() Add stubs for dw_scrollbox_get_pos() and dw_scrollbox_get_range() Fix bug with dw_text_new(); did not allow & in text content Only call default window procedure from _rendproc if the user didn't handle the message themselves
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 19 Mar 2011 00:37:08 +0000
parents 90d242bacd87
children 2dd7638a7719
comparison
equal deleted inserted replaced
770:90d242bacd87 771:5cca4ebcca9a
35 HINSTANCE DWInstance = NULL; 35 HINSTANCE DWInstance = NULL;
36 36
37 DWORD dwVersion = 0, dwComctlVer = 0; 37 DWORD dwVersion = 0, dwComctlVer = 0;
38 DWTID _dwtid = -1; 38 DWTID _dwtid = -1;
39 SECURITY_DESCRIPTOR _dwsd; 39 SECURITY_DESCRIPTOR _dwsd;
40
41 static HFONT DefaultBoldFont;
42 static LOGFONT lfDefaultBoldFont = { 0 };
40 43
41 #define PACKVERSION(major,minor) MAKELONG(minor,major) 44 #define PACKVERSION(major,minor) MAKELONG(minor,major)
42 45
43 #define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80)) 46 #define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80))
44 #define IS_WINNTOR95 (((LOBYTE(LOWORD(dwVersion))) < 5) && (HIBYTE(LOWORD(dwVersion)) < 10)) 47 #define IS_WINNTOR95 (((LOBYTE(LOWORD(dwVersion))) < 5) && (HIBYTE(LOWORD(dwVersion)) < 10))
531 } 534 }
532 } 535 }
533 free(array); 536 free(array);
534 } 537 }
535 } 538 }
539 else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0)
540 {
541 /* for spinbuttons, we need to get the spinbutton's "buddy", the text window associated and destroy it */
542 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
543
544 if(cinfo && cinfo->buddy)
545 DestroyWindow( cinfo->buddy );
546 }
536 547
537 dw_signal_disconnect_by_window(handle); 548 dw_signal_disconnect_by_window(handle);
538 549
539 if(thiscinfo) 550 if(thiscinfo)
540 { 551 {
1461 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); 1472 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
1462 } 1473 }
1463 } 1474 }
1464 } 1475 }
1465 1476
1466 int _HandleScroller(HWND handle, int pos, int which) 1477 int _HandleScroller(HWND handle, int bar, int pos, int which)
1467 { 1478 {
1468 SCROLLINFO si; 1479 SCROLLINFO si;
1469 1480 #ifndef SCROLLBOX_DEBUG
1481 char lasterror[257];
1482 #endif
1483
1484 ZeroMemory( &si, sizeof(si) );
1470 si.cbSize = sizeof(SCROLLINFO); 1485 si.cbSize = sizeof(SCROLLINFO);
1471 si.fMask = SIF_ALL; 1486 si.fMask = SIF_ALL;
1472 1487
1473 SendMessage(handle, SBM_GETSCROLLINFO, 0, (LPARAM)&si); 1488 SendMessage(handle, SBM_GETSCROLLINFO, 0, (LPARAM)&si);
1489 #ifndef SCROLLBOX_DEBUG
1490 FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT), lasterror, 256, NULL);
1491 _dw_log( "Error from SendMessage in _HandleScroller: Handle %x Bar %s(%d) Which %d: %s", handle, (bar==SB_HORZ)?"HORZ" : "VERT", bar, which,lasterror );
1492 #endif
1493
1494 ZeroMemory( &si, sizeof(si) );
1495 si.cbSize = sizeof(SCROLLINFO);
1496 si.fMask = SIF_ALL;
1497 #ifndef SCROLLBOX_DEBUG
1498 GetScrollInfo( handle, bar, &si );
1499 _dw_log( "Error from GetScrollInfo in _HandleScroller: Handle %x Bar %s(%d) Which %d: %s", handle, (bar==SB_HORZ)?"HORZ" : "VERT", bar, which,lasterror );
1500 #endif
1474 1501
1475 switch(which) 1502 switch(which)
1476 { 1503 {
1477 case SB_THUMBTRACK: 1504 case SB_THUMBTRACK:
1478 return pos; 1505 return pos;
2059 char tmpbuf[100]; 2086 char tmpbuf[100];
2060 HWND handle = (HWND)mp2; 2087 HWND handle = (HWND)mp2;
2061 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction; 2088 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
2062 2089
2063 GetClassName(handle, tmpbuf, 99); 2090 GetClassName(handle, tmpbuf, 99);
2064 2091 #ifndef SCROLLBOX_DEBUG
2092 dw_messagebox("Scrollbar", DW_MB_OK, "%s %d: %s",__FILE__,__LINE__,tmpbuf);
2093 #endif
2065 if (strnicmp(tmpbuf, TRACKBAR_CLASS, strlen(TRACKBAR_CLASS)+1)==0) 2094 if (strnicmp(tmpbuf, TRACKBAR_CLASS, strlen(TRACKBAR_CLASS)+1)==0)
2066 { 2095 {
2067 2096
2068 if (handle == tmp->window) 2097 if (handle == tmp->window)
2069 { 2098 {
2078 tmp = NULL; 2107 tmp = NULL;
2079 } 2108 }
2080 } 2109 }
2081 else if(strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1)==0) 2110 else if(strnicmp(tmpbuf, SCROLLBARCLASSNAME, strlen(SCROLLBARCLASSNAME)+1)==0)
2082 { 2111 {
2112 #ifndef SCROLLBOX_DEBUG
2113 dw_messagebox("Scrollbar", DW_MB_OK, "%s %d",__FILE__,__LINE__);
2114 #endif
2083 if(handle == tmp->window) 2115 if(handle == tmp->window)
2084 { 2116 {
2085 int value = _HandleScroller(handle, (int)HIWORD(mp1), (int)LOWORD(mp1)); 2117 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT;
2118 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
2086 2119
2087 if(value > -1) 2120 if(value > -1)
2088 { 2121 {
2089 dw_scrollbar_set_pos(tmp->window, value); 2122 dw_scrollbar_set_pos(tmp->window, value);
2090 result = valuechangefunc(tmp->window, value, tmp->data); 2123 result = valuechangefunc(tmp->window, value, tmp->data);
2187 SetParent(array[num]->hwnd, tem->hwndFrom); 2220 SetParent(array[num]->hwnd, tem->hwndFrom);
2188 2221
2189 _resize_notebook_page(tem->hwndFrom, num); 2222 _resize_notebook_page(tem->hwndFrom, num);
2190 } 2223 }
2191 #ifdef DWDEBUG 2224 #ifdef DWDEBUG
2225 // code to attempt to support containers with different colours for each row - incomplete
2192 else 2226 else
2193 { 2227 {
2194 /* 2228 /*
2195 * Check if we have a click_default for this window 2229 * Check if we have a click_default for this window
2196 */ 2230 */
2212 case WM_HSCROLL: 2246 case WM_HSCROLL:
2213 case WM_VSCROLL: 2247 case WM_VSCROLL:
2214 { 2248 {
2215 HWND handle = (HWND)mp2; 2249 HWND handle = (HWND)mp2;
2216 char tmpbuf[100]; 2250 char tmpbuf[100];
2251 int bar = (origmsg == WM_HSCROLL) ? SB_HORZ : SB_VERT;
2217 2252
2218 if(dw_window_get_data(handle, "_dw_scrollbar")) 2253 if(dw_window_get_data(handle, "_dw_scrollbar"))
2219 { 2254 {
2220 int value = _HandleScroller(handle, (int)HIWORD(mp1), (int)LOWORD(mp1)); 2255 int value = _HandleScroller(handle, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
2221 2256
2222 if(value > -1) 2257 if(value > -1)
2223 dw_scrollbar_set_pos(handle, value); 2258 dw_scrollbar_set_pos(handle, value);
2224 } 2259 }
2225 GetClassName( hWnd, tmpbuf, 99 ); 2260 else
2226 if ( strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 )
2227 { 2261 {
2228 int value = _HandleScroller(hWnd, (int)HIWORD(mp1), (int)LOWORD(mp1)); 2262 GetClassName( hWnd, tmpbuf, 99 );
2229 } } 2263 if ( strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 )
2264 {
2265 int value = _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
2266 #ifndef SCROLLBOX_DEBUG
2267 /*
2268 * now we have the position we need to scroll the client window
2269 * and set the scrollbar to the specified position
2270 */
2271 _dw_log( "After _HandleScroller: Got scroll for scrollbox: %d Handle %x hWnd %x\n", value,handle, hWnd );
2272 if(value > -1)
2273 {
2274 char lasterror[257];
2275 SetScrollPos(hWnd, bar, value, TRUE);
2276 FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT), lasterror, 256, NULL);
2277 _dw_log( "Error from setscrollpos: %s", lasterror );
2278 // dw_scrollbar_set_pos(handle, value);
2279 }
2280 #endif
2281 }
2282 }
2283 }
2230 break; 2284 break;
2231 case WM_GETMINMAXINFO: 2285 case WM_GETMINMAXINFO:
2232 { 2286 {
2233 MINMAXINFO *info = (MINMAXINFO *)mp2; 2287 MINMAXINFO *info = (MINMAXINFO *)mp2;
2234 info->ptMinTrackSize.x = 8; 2288 info->ptMinTrackSize.x = 8;
2443 { 2497 {
2444 RECT wndRect; 2498 RECT wndRect;
2445 POINTS points; 2499 POINTS points;
2446 POINT point; 2500 POINT point;
2447 int threadid = dw_thread_id(); 2501 int threadid = dw_thread_id();
2448 2502 BOOL rcode = TRUE;
2449 2503
2450 switch( msg ) 2504 switch( msg )
2451 { 2505 {
2452 case WM_LBUTTONDOWN: 2506 case WM_LBUTTONDOWN:
2453 case WM_MBUTTONDOWN: 2507 case WM_MBUTTONDOWN:
2454 case WM_RBUTTONDOWN: 2508 case WM_RBUTTONDOWN:
2455 SetFocus(hWnd); 2509 SetFocus(hWnd);
2456 _wndproc(hWnd, msg, mp1, mp2); 2510 rcode = _wndproc(hWnd, msg, mp1, mp2);
2511 #ifndef SCROLLBOX_DEBUG
2512 _dw_log( "_renderproc: button down: %d\n", rcode );
2513 #endif
2457 break; 2514 break;
2458 case WM_MOUSEMOVE: 2515 case WM_MOUSEMOVE:
2459 if ( threadid < 0 || threadid >= THREAD_LIMIT ) 2516 if ( threadid < 0 || threadid >= THREAD_LIMIT )
2460 threadid = 0; 2517 threadid = 0;
2461 /* 2518 /*
2483 { 2540 {
2484 ReleaseCapture(); 2541 ReleaseCapture();
2485 _PointerOnWnd[threadid] = 0; 2542 _PointerOnWnd[threadid] = 0;
2486 } 2543 }
2487 /* call our standard Windows procedure */ 2544 /* call our standard Windows procedure */
2488 _wndproc(hWnd, msg, mp1, mp2); 2545 rcode = _wndproc(hWnd, msg, mp1, mp2);
2489 break; 2546 break;
2490 case WM_LBUTTONUP: 2547 case WM_LBUTTONUP:
2491 case WM_MBUTTONUP: 2548 case WM_MBUTTONUP:
2492 case WM_RBUTTONUP: 2549 case WM_RBUTTONUP:
2550 rcode = _wndproc(hWnd, msg, mp1, mp2);
2551 #ifndef SCROLLBOX_DEBUG
2552 _dw_log( "_renderproc: button up: %d\n", rcode );
2553 #endif
2554 break;
2493 case WM_PAINT: 2555 case WM_PAINT:
2494 case WM_SIZE: 2556 case WM_SIZE:
2495 case WM_COMMAND: 2557 case WM_COMMAND:
2496 case WM_CHAR: 2558 case WM_CHAR:
2497 case WM_KEYDOWN: 2559 case WM_KEYDOWN:
2498 _wndproc(hWnd, msg, mp1, mp2); 2560 rcode = _wndproc(hWnd, msg, mp1, mp2);
2499 break; 2561 break;
2500 } 2562 default:
2501 return DefWindowProc(hWnd, msg, mp1, mp2); 2563 // rcode = DefWindowProc(hWnd, msg, mp1, mp2);
2564 break;
2565 }
2566 /* only call the default Windows process if the user hasn't handled the message themselves */
2567 if ( rcode != 0 )
2568 rcode = DefWindowProc(hWnd, msg, mp1, mp2);
2569 return rcode;
2502 } 2570 }
2503 2571
2504 BOOL CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) 2572 BOOL CALLBACK _spinnerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
2505 { 2573 {
2506 ColorInfo *cinfo; 2574 ColorInfo *cinfo;
3400 void _create_tooltip(HWND handle, char *text) 3468 void _create_tooltip(HWND handle, char *text)
3401 { 3469 {
3402 /* Create a tooltip. */ 3470 /* Create a tooltip. */
3403 HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST, 3471 HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
3404 TOOLTIPS_CLASS, NULL, 3472 TOOLTIPS_CLASS, NULL,
3405 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, 3473 WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
3406 CW_USEDEFAULT, CW_USEDEFAULT, 3474 CW_USEDEFAULT, CW_USEDEFAULT,
3407 CW_USEDEFAULT, CW_USEDEFAULT, 3475 CW_USEDEFAULT, CW_USEDEFAULT,
3408 handle, NULL, DWInstance,NULL); 3476 handle, NULL, DWInstance,NULL);
3409 TOOLINFO ti = { 0 }; 3477 TOOLINFO ti = { 0 };
3410 3478
3411 SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 3479 SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
3412 3480
3413 /* Set up "tool" information. 3481 /* Set up "tool" information.
3414 * In this case, the "tool" is the entire parent window. 3482 * In this case, the "tool" is the entire parent window.
3415 */ 3483 */
3416 ti.cbSize = sizeof(TOOLINFO); 3484 ti.cbSize = sizeof(TOOLINFO);
3417 ti.uFlags = TTF_SUBCLASS; 3485 ti.uFlags = TTF_SUBCLASS;
3418 ti.hwnd = handle; 3486 ti.hwnd = handle;
3419 ti.hinst = DWInstance; 3487 ti.hinst = DWInstance;
3420 ti.lpszText = text; 3488 ti.lpszText = text;
3421 GetClientRect(handle, &ti.rect); 3489 GetClientRect(handle, &ti.rect);
3422 3490
3423 /* Associate the tooltip with the "tool" window. */ 3491 /* Associate the tooltip with the "tool" window. */
3424 SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); 3492 SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
3425 } 3493 }
3426 3494
3427 3495
3428 /* This function determines the handle for a supplied image filename 3496 /* This function determines the handle for a supplied image filename
3429 */ 3497 */
3430 int _dw_get_image_handle(char *filename, HANDLE *icon, HBITMAP *hbitmap) 3498 int _dw_get_image_handle(char *filename, HANDLE *icon, HBITMAP *hbitmap)
3502 { 3570 {
3503 WNDCLASS wc; 3571 WNDCLASS wc;
3504 int z; 3572 int z;
3505 INITCOMMONCONTROLSEX icc; 3573 INITCOMMONCONTROLSEX icc;
3506 char *fname; 3574 char *fname;
3575 HFONT oldfont;
3507 3576
3508 icc.dwSize = sizeof(INITCOMMONCONTROLSEX); 3577 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
3509 icc.dwICC = ICC_WIN95_CLASSES|ICC_DATE_CLASSES; 3578 icc.dwICC = ICC_WIN95_CLASSES|ICC_DATE_CLASSES;
3510 3579
3511 InitCommonControlsEx(&icc); 3580 InitCommonControlsEx(&icc);
3633 * and dw_screen-height() quicker, but to alos limit the 3702 * and dw_screen-height() quicker, but to alos limit the
3634 * default size of windows. 3703 * default size of windows.
3635 */ 3704 */
3636 screenx = GetSystemMetrics(SM_CXSCREEN); 3705 screenx = GetSystemMetrics(SM_CXSCREEN);
3637 screeny = GetSystemMetrics(SM_CYSCREEN); 3706 screeny = GetSystemMetrics(SM_CYSCREEN);
3707 /*
3708 * Create a default bold font
3709 */
3710 oldfont = GetStockObject(DEFAULT_GUI_FONT);
3711 GetObject( oldfont, sizeof(lfDefaultBoldFont), &lfDefaultBoldFont );
3712 lfDefaultBoldFont.lfWeight = FW_BOLD;
3713 DefaultBoldFont = CreateFontIndirect(&lfDefaultBoldFont);
3638 return 0; 3714 return 0;
3639 } 3715 }
3640 3716
3641 /* 3717 /*
3642 * Runs a message loop for Dynamic Windows. 3718 * Runs a message loop for Dynamic Windows.
3979 for(z=0;z<strlen(fontname);z++) 4055 for(z=0;z<strlen(fontname);z++)
3980 { 4056 {
3981 if(fontname[z]=='.') 4057 if(fontname[z]=='.')
3982 break; 4058 break;
3983 } 4059 }
3984 size = atoi(fontname) + 5; 4060 size = atoi(fontname) + 5; /* no idea why this 5 needs to be added */
3985 Italic = instring(" Italic", &fontname[z+1]); 4061 Italic = instring(" Italic", &fontname[z+1]);
3986 Bold = instring(" Bold", &fontname[z+1]); 4062 Bold = instring(" Bold", &fontname[z+1]);
3987 #if 0 4063 #if 0
3988 lf.lfHeight = -MulDiv(size, GetDeviceCaps(hDC, LOGPIXELSY), 72); 4064 lf.lfHeight = -MulDiv(size, GetDeviceCaps(hDC, LOGPIXELSY), 72);
3989 #endif 4065 #endif
4030 int API dw_window_set_font(HWND handle, char *fontname) 4106 int API dw_window_set_font(HWND handle, char *fontname)
4031 { 4107 {
4032 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); 4108 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
4033 HFONT hfont = _acquire_font(handle, fontname); 4109 HFONT hfont = _acquire_font(handle, fontname);
4034 ColorInfo *cinfo; 4110 ColorInfo *cinfo;
4111 Box *thisbox;
4112 char tmpbuf[100];
4035 4113
4036 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 4114 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4037 4115
4038 if(fontname) 4116 if (fontname)
4039 { 4117 {
4118 GetClassName(handle, tmpbuf, 99);
4119 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)) == 0 )
4120 {
4121 /* groupbox */
4122 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
4123 if ( thisbox && thisbox->grouphwnd != (HWND)NULL )
4124 {
4125 handle = thisbox->grouphwnd;
4126 }
4127 }
4040 if(cinfo) 4128 if(cinfo)
4041 { 4129 {
4042 strcpy(cinfo->fontname, fontname); 4130 strcpy(cinfo->fontname, fontname);
4043 if(!oldfont) 4131 if(!oldfont)
4044 oldfont = cinfo->hfont; 4132 oldfont = cinfo->hfont;
4060 DeleteObject(oldfont); 4148 DeleteObject(oldfont);
4061 return 0; 4149 return 0;
4062 } 4150 }
4063 4151
4064 /* 4152 /*
4153 * Gets the font used by a specified window (widget) handle.
4154 * Parameters:
4155 * handle: The window (widget) handle.
4156 * fontname: Name and size of the font in the form "size.fontname"
4157 */
4158 char * API dw_window_get_font(HWND handle)
4159 {
4160 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
4161 char *str = NULL;
4162 char *bold = "";
4163 char *italic = "";
4164 LOGFONT lf = { 0 };
4165
4166 if ( GetObject( oldfont, sizeof(lf), &lf ) )
4167 {
4168 str = (char *)malloc( 100 );
4169 if ( str )
4170 {
4171 int height;
4172 if ( lf.lfWeight > FW_MEDIUM )
4173 bold = " Bold";
4174 if ( lf.lfItalic )
4175 italic = " Italic";
4176 if ( lf.lfHeight <= 0 )
4177 height = abs (lf.lfHeight );
4178 else
4179 /*
4180 * we subtract 5 from a positive font height, because we (presumably)
4181 * added 5 (in _acquire_font() above - don't know why )
4182 */
4183 height = lf.lfHeight - 5;
4184 sprintf( str, "%d.%s%s%s", height, lf.lfFaceName, bold, italic );
4185 }
4186 else
4187 str = "";
4188 }
4189 else
4190 str = "";
4191 if ( oldfont )
4192 DeleteObject( oldfont );
4193 #if 0
4194 {
4195 HWND hwnd=NULL; // owner window
4196 HDC hdc; // display device context of owner window
4197
4198 CHOOSEFONT cf; // common dialog box structure
4199 LOGFONT lf; // logical font structure
4200 HFONT hfont, hfontPrev;
4201
4202 // Initialize CHOOSEFONT
4203 ZeroMemory(&cf, sizeof(cf));
4204 cf.lStructSize = sizeof (cf);
4205 cf.hwndOwner = hwnd;
4206 cf.lpLogFont = &lf;
4207 cf.Flags = CF_SCREENFONTS | CF_EFFECTS;
4208
4209 if (ChooseFont(&cf)==TRUE)
4210 {
4211 hfont = CreateFontIndirect(cf.lpLogFont);
4212 }
4213 }
4214 #endif
4215 return str;
4216 }
4217
4218 /*
4065 * Sets the colors used by a specified window (widget) handle. 4219 * Sets the colors used by a specified window (widget) handle.
4066 * Parameters: 4220 * Parameters:
4067 * handle: The window (widget) handle. 4221 * handle: The window (widget) handle.
4068 * fore: Foreground color in RGB format. 4222 * fore: Foreground color in RGB format.
4069 * back: Background color in RGB format. 4223 * back: Background color in RGB format.
4070 */ 4224 */
4071 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back) 4225 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
4072 { 4226 {
4073 ColorInfo *cinfo; 4227 ColorInfo *cinfo;
4074 Box *newbox; 4228 Box *thisbox;
4075 char tmpbuf[100]; 4229 char tmpbuf[100];
4076 4230
4077 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 4231 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4078 newbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4079 4232
4080 GetClassName(handle, tmpbuf, 99); 4233 GetClassName(handle, tmpbuf, 99);
4081 4234
4082 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0) 4235 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0)
4083 { 4236 {
4094 DW_GREEN_VALUE(back), 4247 DW_GREEN_VALUE(back),
4095 DW_BLUE_VALUE(back))); 4248 DW_BLUE_VALUE(back)));
4096 InvalidateRgn(handle, NULL, TRUE); 4249 InvalidateRgn(handle, NULL, TRUE);
4097 return TRUE; 4250 return TRUE;
4098 } 4251 }
4252 else if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)) == 0 )
4253 {
4254 /* groupbox */
4255 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
4256 if ( thisbox && thisbox->grouphwnd != (HWND)NULL )
4257 {
4258 thisbox->cinfo.fore = fore;
4259 thisbox->cinfo.back = back;
4260 }
4261 }
4099 4262
4100 if(cinfo) 4263 if(cinfo)
4101 { 4264 {
4102 cinfo->fore = fore; 4265 cinfo->fore = fore;
4103 cinfo->back = back; 4266 cinfo->back = back;
4268 newbox->grouphwnd = (HWND)NULL; 4431 newbox->grouphwnd = (HWND)NULL;
4269 newbox->cinfo.fore = newbox->cinfo.back = -1; 4432 newbox->cinfo.fore = newbox->cinfo.back = -1;
4270 4433
4271 hwndframe = CreateWindow(FRAMECLASSNAME, 4434 hwndframe = CreateWindow(FRAMECLASSNAME,
4272 "", 4435 "",
4273 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL, 4436 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_THICKFRAME,
4274 0,0,2000,1000, 4437 0,0,2000,1000,
4275 DW_HWND_OBJECT, 4438 DW_HWND_OBJECT,
4276 NULL, 4439 NULL,
4277 DWInstance, 4440 DWInstance,
4278 NULL); 4441 NULL);
4279 4442
4280 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc); 4443 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
4281 newbox->cinfo.fore = newbox->cinfo.back = -1; 4444 newbox->cinfo.fore = newbox->cinfo.back = -1;
4282 4445
4283 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); 4446 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4447 _dw_log( "Handle for scrollbox %x\n", hwndframe);
4284 return hwndframe; 4448 return hwndframe;
4285 } 4449 }
4286 4450
4451 int dw_scrollbox_get_pos( HWND handle, int orient )
4452 {
4453 return 0;
4454 }
4455
4456 int dw_scrollbox_get_range( HWND handle, int orient )
4457 {
4458 return 0;
4459 }
4287 /* 4460 /*
4288 * Create a new Group Box to be packed. 4461 * Create a new Group Box to be packed.
4289 * Parameters: 4462 * Parameters:
4290 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 4463 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
4291 * pad: Number of pixels to pad around the box. 4464 * pad: Number of pixels to pad around the box.
4319 NULL, 4492 NULL,
4320 DWInstance, 4493 DWInstance,
4321 NULL); 4494 NULL);
4322 4495
4323 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); 4496 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4324 dw_window_set_font(newbox->grouphwnd, DefaultFont); 4497 /*
4498 * Set the text on the frame to our default bold font
4499 */
4500 SendMessage(newbox->grouphwnd, WM_SETFONT, (WPARAM)DefaultBoldFont, (LPARAM)TRUE);
4325 return hwndframe; 4501 return hwndframe;
4326 } 4502 }
4327 4503
4328 /* 4504 /*
4329 * Create a new MDI Frame to be packed. 4505 * Create a new MDI Frame to be packed.
4855 */ 5031 */
4856 HWND API dw_text_new(char *text, ULONG id) 5032 HWND API dw_text_new(char *text, ULONG id)
4857 { 5033 {
4858 HWND tmp = CreateWindow(STATICCLASSNAME, 5034 HWND tmp = CreateWindow(STATICCLASSNAME,
4859 text, 5035 text,
5036 SS_NOPREFIX |
4860 BS_TEXT | WS_VISIBLE | 5037 BS_TEXT | WS_VISIBLE |
4861 WS_CHILD | WS_CLIPCHILDREN, 5038 WS_CHILD | WS_CLIPCHILDREN,
4862 0,0,2000,1000, 5039 0,0,2000,1000,
4863 DW_HWND_OBJECT, 5040 DW_HWND_OBJECT,
4864 (HMENU)id, 5041 (HMENU)id,
5089 DWInstance, 5266 DWInstance,
5090 NULL); 5267 NULL);
5091 5268
5092 bubble->cinfo.fore = bubble->cinfo.back = -1; 5269 bubble->cinfo.fore = bubble->cinfo.back = -1;
5093 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); 5270 bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc);
5094 5271
5095 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble); 5272 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble);
5096 5273
5097 _create_tooltip(tmp, text); 5274 _create_tooltip(tmp, text);
5098 5275
5099 if(icon) 5276 if(icon)
7548 else if(flags[column] & DW_CFA_DATE) 7725 else if(flags[column] & DW_CFA_DATE)
7549 { 7726 {
7550 struct tm curtm; 7727 struct tm curtm;
7551 CDATE cdate = *((CDATE *)data); 7728 CDATE cdate = *((CDATE *)data);
7552 7729
7553 memset(&curtm, 0, sizeof(struct tm)); 7730 memset(&curtm, 0, sizeof(struct tm));
7554 7731
7555 /* Safety check... zero dates are crashing 7732 /* Safety check... zero dates are crashing
7556 * Visual Studio 2008. -Brian 7733 * Visual Studio 2008. -Brian
7557 */ 7734 */
7558 if(cdate.year > 1900 && cdate.year < 2100) 7735 if(cdate.year > 1900 && cdate.year < 2100)
7559 { 7736 {
7560 curtm.tm_mday = (cdate.day >= 0 && cdate.day < 32) ? cdate.day : 1; 7737 curtm.tm_mday = (cdate.day >= 0 && cdate.day < 32) ? cdate.day : 1;
7561 curtm.tm_mon = (cdate.month > 0 && cdate.month < 13) ? cdate.month - 1 : 0; 7738 curtm.tm_mon = (cdate.month > 0 && cdate.month < 13) ? cdate.month - 1 : 0;
7562 curtm.tm_year = cdate.year - 1900; 7739 curtm.tm_year = cdate.year - 1900;
7563 7740 strftime(textbuffer, 100, "%x", &curtm);
7564 strftime(textbuffer, 100, "%x", &curtm); 7741 }
7565 } 7742 else
7566 else 7743 {
7567 { 7744 textbuffer[0] = 0;
7568 textbuffer[0] = 0; 7745 }
7569 }
7570 7746
7571 lvi.pszText = textbuffer; 7747 lvi.pszText = textbuffer;
7572 lvi.cchTextMax = strlen(textbuffer); 7748 lvi.cchTextMax = strlen(textbuffer);
7573 } 7749 }
7574 else if(flags[column] & DW_CFA_TIME) 7750 else if(flags[column] & DW_CFA_TIME)
7575 { 7751 {
7576 struct tm curtm; 7752 struct tm curtm;
7577 CTIME ctime = *((CTIME *)data); 7753 CTIME ctime = *((CTIME *)data);
7578 7754
7579 curtm.tm_hour = (ctime.hours >= 0 && ctime.hours < 24) ? ctime.hours : 0; 7755 curtm.tm_hour = (ctime.hours >= 0 && ctime.hours < 24) ? ctime.hours : 0;
7580 curtm.tm_min = (ctime.minutes >= 0 && ctime.minutes < 60) ? ctime.minutes : 0; 7756 curtm.tm_min = (ctime.minutes >= 0 && ctime.minutes < 60) ? ctime.minutes : 0;
7581 curtm.tm_sec = (ctime.seconds >= 0 && ctime.seconds < 60) ? ctime.seconds : 0; 7757 curtm.tm_sec = (ctime.seconds >= 0 && ctime.seconds < 60) ? ctime.seconds : 0;
7582 7758
7583 strftime(textbuffer, 100, "%X", &curtm); 7759 strftime(textbuffer, 100, "%X", &curtm);
7584 7760
9098 * Parameters: 9274 * Parameters:
9099 * exitcode: Exit code reported to the operating system. 9275 * exitcode: Exit code reported to the operating system.
9100 */ 9276 */
9101 void API dw_exit(int exitcode) 9277 void API dw_exit(int exitcode)
9102 { 9278 {
9279 DeleteObject( DefaultBoldFont );
9103 OleUninitialize(); 9280 OleUninitialize();
9104 if ( dbgfp != NULL ) 9281 if ( dbgfp != NULL )
9105 { 9282 {
9106 fclose( dbgfp ); 9283 fclose( dbgfp );
9107 } 9284 }