Mercurial > dwindows
comparison win/dw.c @ 630:6e84e055d981
Attempt to make click_default work properly.
Fix for dw_timer_connect()
Use better directory browser widget.
Fix for dw_container_delete_row() and dw_container_cursor()
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 30 Oct 2008 10:43:16 +0000 |
parents | 7d93356f250a |
children | c6a216c8174f |
comparison
equal
deleted
inserted
replaced
629:a5deb87b26e4 | 630:6e84e055d981 |
---|---|
17 #include <string.h> | 17 #include <string.h> |
18 #include <stdio.h> | 18 #include <stdio.h> |
19 #include <process.h> | 19 #include <process.h> |
20 #include <time.h> | 20 #include <time.h> |
21 #include "dw.h" | 21 #include "dw.h" |
22 #include "XBrowseForFolder.h" | |
22 | 23 |
23 /* | 24 /* |
24 * MinGW (as at 3.2.3) doesn't have MIM_MENUDATA | 25 * MinGW (as at 3.2.3) doesn't have MIM_MENUDATA |
25 * so #define it here | 26 * so #define it here |
26 */ | 27 */ |
80 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); | 81 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
81 void _resize_notebook_page(HWND handle, int pageid); | 82 void _resize_notebook_page(HWND handle, int pageid); |
82 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); | 83 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); |
83 int _lookup_icon(HWND handle, HICON hicon, int type); | 84 int _lookup_icon(HWND handle, HICON hicon, int type); |
84 HFONT _acquire_font(HWND handle, char *fontname); | 85 HFONT _acquire_font(HWND handle, char *fontname); |
86 void _click_default(HWND handle); | |
85 | 87 |
86 typedef struct _sighandler | 88 typedef struct _sighandler |
87 { | 89 { |
88 struct _sighandler *next; | 90 struct _sighandler *next; |
89 ULONG message; | 91 ULONG message; |
311 new->signalfunction = signalfunction; | 313 new->signalfunction = signalfunction; |
312 new->data = data; | 314 new->data = data; |
313 new->next = NULL; | 315 new->next = NULL; |
314 | 316 |
315 if (!Root) | 317 if (!Root) |
318 { | |
316 Root = new; | 319 Root = new; |
320 } | |
317 else | 321 else |
318 { | 322 { |
319 SignalHandler *prev = NULL, *tmp = Root; | 323 SignalHandler *prev = NULL, *tmp = Root; |
320 while(tmp) | 324 while(tmp) |
321 { | 325 { |
1484 { | 1488 { |
1485 int (*timerfunc)(void *) = tmp->signalfunction; | 1489 int (*timerfunc)(void *) = tmp->signalfunction; |
1486 if (tmp->id == (int)mp1) | 1490 if (tmp->id == (int)mp1) |
1487 { | 1491 { |
1488 if (!timerfunc(tmp->data)) | 1492 if (!timerfunc(tmp->data)) |
1493 { | |
1489 dw_timer_disconnect(tmp->id); | 1494 dw_timer_disconnect(tmp->id); |
1495 } | |
1490 tmp = NULL; | 1496 tmp = NULL; |
1491 } | 1497 } |
1492 } | 1498 } |
1493 result = 0; | 1499 result = 0; |
1494 } | 1500 } |
1919 } | 1925 } |
1920 } | 1926 } |
1921 } | 1927 } |
1922 break; | 1928 break; |
1923 case WM_CHAR: | 1929 case WM_CHAR: |
1924 if(LOWORD(mp1) == '\t') | 1930 if ( LOWORD( mp1 ) == '\t' ) |
1925 { | 1931 { |
1926 if(GetAsyncKeyState(VK_SHIFT) & 0x8000) | 1932 if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) |
1927 _shift_focus_back(hWnd); | 1933 _shift_focus_back( hWnd ); |
1928 else | 1934 else |
1929 _shift_focus(hWnd); | 1935 _shift_focus( hWnd ); |
1930 return TRUE; | 1936 return TRUE; |
1937 } | |
1938 else if( LOWORD( mp1 ) == '\r' ) | |
1939 { | |
1940 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr( hWnd, GWLP_USERDATA ); | |
1941 if ( cinfo && cinfo->clickdefault ) | |
1942 { | |
1943 _click_default( cinfo->clickdefault ); | |
1944 } | |
1931 } | 1945 } |
1932 break; | 1946 break; |
1933 case WM_USER: | 1947 case WM_USER: |
1934 windowfunc = (void *)mp1; | 1948 windowfunc = (void *)mp1; |
1935 | 1949 |
2366 | 2380 |
2367 GetClassName(hWnd, tmpbuf, 99); | 2381 GetClassName(hWnd, tmpbuf, 99); |
2368 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) | 2382 if(strcmp(tmpbuf, FRAMECLASSNAME) == 0) |
2369 cinfo = &(((Box *)cinfo)->cinfo); | 2383 cinfo = &(((Box *)cinfo)->cinfo); |
2370 | 2384 |
2371 if(msg == WM_MOUSEMOVE) | 2385 if ( msg == WM_MOUSEMOVE ) |
2372 _wndproc(hWnd, msg, mp1, mp2); | 2386 _wndproc(hWnd, msg, mp1, mp2); |
2373 | 2387 |
2374 if (cinfo) | 2388 if (cinfo) |
2375 { | 2389 { |
2376 pOldProc = cinfo->pOldProc; | 2390 pOldProc = cinfo->pOldProc; |
2457 } | 2471 } |
2458 return FALSE; | 2472 return FALSE; |
2459 } | 2473 } |
2460 else if(LOWORD(mp1) == '\r') | 2474 else if(LOWORD(mp1) == '\r') |
2461 { | 2475 { |
2462 if (cinfo->clickdefault) | 2476 |
2477 if ( cinfo->clickdefault ) | |
2463 { | 2478 { |
2464 _click_default(cinfo->clickdefault); | 2479 _click_default(cinfo->clickdefault); |
2480 } | |
2481 else | |
2482 { | |
2483 /* | |
2484 * Find the toplevel window for the current window and check if it | |
2485 * has a default click set | |
2486 */ | |
2487 HWND tl = _toplevel_window( hWnd ); | |
2488 ColorInfo *mycinfo = (ColorInfo *)GetWindowLongPtr( tl, GWLP_USERDATA ); | |
2489 if ( mycinfo && cinfo->clickdefault ) | |
2490 { | |
2491 _click_default( mycinfo->clickdefault ); | |
2492 } | |
2465 } | 2493 } |
2466 } | 2494 } |
2467 | 2495 |
2468 /* Tell the spinner control that a keypress has | 2496 /* Tell the spinner control that a keypress has |
2469 * occured and to update it's internal value. | 2497 * occured and to update it's internal value. |
3145 /* Calling ReleaseCapture in Win95 also causes WM_CAPTURECHANGED | 3173 /* Calling ReleaseCapture in Win95 also causes WM_CAPTURECHANGED |
3146 * to be sent. Be sure to account for that. | 3174 * to be sent. Be sure to account for that. |
3147 */ | 3175 */ |
3148 ReleaseCapture(); | 3176 ReleaseCapture(); |
3149 | 3177 |
3150 if(bMouseOver) | 3178 if(bMouseOver && hwndBubble) |
3151 { | 3179 { |
3152 bMouseOver = 0; | 3180 bMouseOver = 0; |
3153 _free_window_memory(hwndBubble, 0); | 3181 _free_window_memory(hwndBubble, 0); |
3154 DestroyWindow(hwndBubble); | 3182 DestroyWindow(hwndBubble); |
3155 hwndBubble = 0; | 3183 hwndBubble = 0; |
3160 case WM_CAPTURECHANGED: | 3188 case WM_CAPTURECHANGED: |
3161 /* This message means we are losing the capture for some reason | 3189 /* This message means we are losing the capture for some reason |
3162 * Either because we intentionally lost it or another window | 3190 * Either because we intentionally lost it or another window |
3163 * stole it | 3191 * stole it |
3164 */ | 3192 */ |
3165 if(bMouseOver) | 3193 if(bMouseOver && hwndBubble) |
3166 { | 3194 { |
3167 bMouseOver = 0; | 3195 bMouseOver = 0; |
3168 _free_window_memory(hwndBubble, 0); | 3196 _free_window_memory(hwndBubble, 0); |
3169 DestroyWindow(hwndBubble); | 3197 DestroyWindow(hwndBubble); |
3170 hwndBubble = 0; | 3198 hwndBubble = 0; |
7525 */ | 7553 */ |
7526 void API dw_container_cursor(HWND handle, char *text) | 7554 void API dw_container_cursor(HWND handle, char *text) |
7527 { | 7555 { |
7528 int index = ListView_GetNextItem(handle, -1, LVNI_ALL); | 7556 int index = ListView_GetNextItem(handle, -1, LVNI_ALL); |
7529 | 7557 |
7530 while(index != -1) | 7558 while ( index != -1 ) |
7531 { | 7559 { |
7532 LV_ITEM lvi; | 7560 LV_ITEM lvi; |
7533 | 7561 |
7534 memset(&lvi, 0, sizeof(LV_ITEM)); | 7562 memset(&lvi, 0, sizeof(LV_ITEM)); |
7535 | 7563 |
7536 lvi.iItem = index; | 7564 lvi.iItem = index; |
7537 lvi.mask = LVIF_PARAM; | 7565 lvi.mask = LVIF_PARAM; |
7538 | 7566 |
7539 ListView_GetItem(handle, &lvi); | 7567 ListView_GetItem( handle, &lvi ); |
7540 | 7568 |
7541 if((char *)lvi.lParam == text) | 7569 if ( strcmp( (char *)lvi.lParam, text ) == 0 ) |
7542 { | 7570 { |
7543 | 7571 |
7544 ListView_SetItemState(handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); | 7572 ListView_SetItemState( handle, index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED ); |
7545 ListView_EnsureVisible(handle, index, TRUE); | 7573 ListView_EnsureVisible( handle, index, TRUE ); |
7546 return; | 7574 return; |
7547 } | 7575 } |
7548 | 7576 |
7549 index = ListView_GetNextItem(handle, index, LVNI_ALL); | 7577 index = ListView_GetNextItem( handle, index, LVNI_ALL ); |
7550 } | 7578 } |
7551 } | 7579 } |
7552 | 7580 |
7553 /* | 7581 /* |
7554 * Deletes the item with the text speficied. | 7582 * Deletes the item with the text speficied. |
7569 lvi.iItem = index; | 7597 lvi.iItem = index; |
7570 lvi.mask = LVIF_PARAM; | 7598 lvi.mask = LVIF_PARAM; |
7571 | 7599 |
7572 ListView_GetItem(handle, &lvi); | 7600 ListView_GetItem(handle, &lvi); |
7573 | 7601 |
7574 if((char *)lvi.lParam == text) | 7602 if ( strcmp( (char *)lvi.lParam, text ) == 0 ) |
7575 { | 7603 { |
7576 int _index = (int)dw_window_get_data(handle, "_dw_index"); | 7604 int _index = (int)dw_window_get_data(handle, "_dw_index"); |
7577 | 7605 |
7578 if(index < _index) | 7606 if(index < _index) |
7579 dw_window_set_data(handle, "_dw_index", (void *)(_index - 1)); | 7607 dw_window_set_data(handle, "_dw_index", (void *)(_index - 1)); |
8977 void API dw_window_click_default(HWND window, HWND next) | 9005 void API dw_window_click_default(HWND window, HWND next) |
8978 { | 9006 { |
8979 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA); | 9007 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA); |
8980 | 9008 |
8981 if (cinfo) | 9009 if (cinfo) |
9010 { | |
8982 cinfo->clickdefault = next; | 9011 cinfo->clickdefault = next; |
9012 } | |
8983 } | 9013 } |
8984 | 9014 |
8985 /* | 9015 /* |
8986 * Gets the contents of the default clipboard as text. | 9016 * Gets the contents of the default clipboard as text. |
8987 * Parameters: | 9017 * Parameters: |
9128 BROWSEINFO bi; | 9158 BROWSEINFO bi; |
9129 TCHAR szDir[MAX_PATH]; | 9159 TCHAR szDir[MAX_PATH]; |
9130 LPITEMIDLIST pidl; | 9160 LPITEMIDLIST pidl; |
9131 LPMALLOC pMalloc; | 9161 LPMALLOC pMalloc; |
9132 | 9162 |
9133 if(flags==DW_DIRECTORY_OPEN) | 9163 if ( flags == DW_DIRECTORY_OPEN ) |
9134 { | 9164 { |
9165 #if 0 | |
9135 if (SUCCEEDED(SHGetMalloc(&pMalloc))) | 9166 if (SUCCEEDED(SHGetMalloc(&pMalloc))) |
9136 { | 9167 { |
9137 ZeroMemory(&bi,sizeof(bi)); | 9168 ZeroMemory(&bi,sizeof(bi)); |
9138 bi.hwndOwner = NULL; | 9169 bi.hwndOwner = NULL; |
9139 bi.pszDisplayName = 0; | 9170 bi.pszDisplayName = 0; |
9154 pMalloc->lpVtbl->Free(pMalloc,pidl); | 9185 pMalloc->lpVtbl->Free(pMalloc,pidl); |
9155 pMalloc->lpVtbl->Release(pMalloc); | 9186 pMalloc->lpVtbl->Release(pMalloc); |
9156 return strdup(filenamebuf); | 9187 return strdup(filenamebuf); |
9157 } | 9188 } |
9158 } | 9189 } |
9190 #else | |
9191 if ( XBrowseForFolder( NULL, | |
9192 (LPCTSTR)defpath, | |
9193 -1, | |
9194 (LPCTSTR)title, | |
9195 (LPTSTR)filenamebuf, | |
9196 1000, | |
9197 FALSE ) ) | |
9198 { | |
9199 return strdup( filenamebuf ); | |
9200 } | |
9201 #endif | |
9159 } | 9202 } |
9160 else | 9203 else |
9161 { | 9204 { |
9162 if (ext) | 9205 if (ext) |
9163 { | 9206 { |