comparison win/dw.c @ 1362:412af8059331

Attempt to get it building with Mingw again... builds but crashes. Fix building DLL without HTML widget support... Mingw is missing required headers. Moved wrapper functions into the main source file so it will export the APIs even if unsupported. Removed debugging code from XBrowseForFolder.cpp because Mingw does not support it.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 18 Nov 2011 18:56:40 +0000
parents 2f5e54b0c5c4
children cdbe26a4b116
comparison
equal deleted inserted replaced
1361:324812debcc9 1362:412af8059331
16 #include <userenv.h> 16 #include <userenv.h>
17 #include <stdlib.h> 17 #include <stdlib.h>
18 #include <string.h> 18 #include <string.h>
19 #include <stdio.h> 19 #include <stdio.h>
20 #include <process.h> 20 #include <process.h>
21 #include <malloc.h>
22 #include <io.h>
21 #include <time.h> 23 #include <time.h>
22 #include <math.h> 24 #include <math.h>
23 #include "dw.h" 25 #include "dw.h"
24 #ifdef BUILD_DLL 26 #ifdef BUILD_DLL
25 #include "XBrowseForFolder.h" 27 #include "XBrowseForFolder.h"
98 /* Token to the GDI+ Instance */ 100 /* Token to the GDI+ Instance */
99 ULONG_PTR gdiplusToken; 101 ULONG_PTR gdiplusToken;
100 #endif 102 #endif
101 103
102 /* 104 /*
103 * MinGW (as at 3.2.3) doesn't have MIM_MENUDATA 105 * MinGW Is missing a bunch of definitions
104 * so #define it here 106 * so #define them here...
105 */ 107 */
106 108
107 #if !defined( MIM_MENUDATA ) 109 #if !defined( MIM_MENUDATA )
108 # define MIM_MENUDATA 0x00000008 110 # define MIM_MENUDATA 0x00000008
111 #endif
112 #if !defined(PBS_MARQUEE)
113 # define PBS_MARQUEE 0x08
114 #endif
115 #if !defined(PBM_SETMARQUEE)
116 # define PBM_SETMARQUEE (WM_USER+10)
117 #endif
118 #if !defined(LVS_EX_DOUBLEBUFFER)
119 # define LVS_EX_DOUBLEBUFFER 0x10000
109 #endif 120 #endif
110 121
111 HWND popup = (HWND)NULL, DW_HWND_OBJECT = (HWND)NULL; 122 HWND popup = (HWND)NULL, DW_HWND_OBJECT = (HWND)NULL;
112 123
113 HINSTANCE DWInstance = NULL; 124 HINSTANCE DWInstance = NULL;
158 HBRUSH _colors[18]; 169 HBRUSH _colors[18];
159 170
160 static int screenx, screeny; 171 static int screenx, screeny;
161 HFONT _DefaultFont = NULL; 172 HFONT _DefaultFont = NULL;
162 173
163 #ifdef BUILD_DLL 174 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
164 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 175 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
165 #endif 176 #endif
166 void _resize_notebook_page(HWND handle, int pageid); 177 void _resize_notebook_page(HWND handle, int pageid);
167 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); 178 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y);
168 int _lookup_icon(HWND handle, HICON hicon, int type); 179 int _lookup_icon(HWND handle, HICON hicon, int type);
389 /* Try various extentions */ 400 /* Try various extentions */
390 for ( i = 0; i < NUM_EXTS; i++ ) 401 for ( i = 0; i < NUM_EXTS; i++ )
391 { 402 {
392 strcpy( file, filename ); 403 strcpy( file, filename );
393 strcat( file, image_exts[i] ); 404 strcat( file, image_exts[i] );
394 if ( access( file, 04 ) == 0 ) 405 if ( _access( file, 04 ) == 0 )
395 { 406 {
396 /* Convert to wide format */ 407 /* Convert to wide format */
397 MultiByteToWideChar(CP_ACP, 0, file, strlen(file)+1, wfile, wclen); 408 MultiByteToWideChar(CP_ACP, 0, file, strlen(file)+1, wfile, wclen);
398 if(!GdipCreateBitmapFromFile(wfile, &image)) 409 if(!GdipCreateBitmapFromFile(wfile, &image))
399 return image; 410 return image;
1705 */ 1716 */
1706 static void _dw_toggle_checkable_menu_item( HWND window, int id ) 1717 static void _dw_toggle_checkable_menu_item( HWND window, int id )
1707 { 1718 {
1708 char buffer[40]; 1719 char buffer[40];
1709 int checkable; 1720 int checkable;
1710 sprintf( buffer, "_dw_checkable%ld", id ); 1721 sprintf( buffer, "_dw_checkable%d", id );
1711 checkable = (int)dw_window_get_data(DW_HWND_OBJECT, buffer); 1722 checkable = (int)dw_window_get_data(DW_HWND_OBJECT, buffer);
1712 if ( checkable ) 1723 if ( checkable )
1713 { 1724 {
1714 int is_checked; 1725 int is_checked;
1715 sprintf( buffer, "_dw_ischecked%ld", id ); 1726 sprintf( buffer, "_dw_ischecked%d", id );
1716 is_checked = (int)dw_window_get_data(DW_HWND_OBJECT, buffer); 1727 is_checked = (int)dw_window_get_data(DW_HWND_OBJECT, buffer);
1717 is_checked = (is_checked) ? 0 : 1; 1728 is_checked = (is_checked) ? 0 : 1;
1718 dw_menu_item_set_check( window, id, is_checked ); 1729 dw_menu_item_set_check( window, id, is_checked );
1719 } 1730 }
1720 } 1731 }
2254 else 2265 else
2255 { 2266 {
2256 GetClassName( hWnd, tmpbuf, 99 ); 2267 GetClassName( hWnd, tmpbuf, 99 );
2257 if ( strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 ) 2268 if ( strnicmp(tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1 ) == 0 )
2258 { 2269 {
2259 int value = _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1)); 2270 _HandleScroller(hWnd, bar, (int)HIWORD(mp1), (int)LOWORD(mp1));
2260 } 2271 }
2261 } 2272 }
2262 } 2273 }
2263 break; 2274 break;
2264 case WM_GETMINMAXINFO: 2275 case WM_GETMINMAXINFO:
2874 } 2885 }
2875 2886
2876 /* Window procedure for container/listview */ 2887 /* Window procedure for container/listview */
2877 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) 2888 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
2878 { 2889 {
2879 ContainerInfo *cinfo; 2890 ContainerInfo *continfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
2880
2881 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
2882 2891
2883 switch( msg ) 2892 switch( msg )
2884 { 2893 {
2885 case WM_COMMAND: 2894 case WM_COMMAND:
2886 case WM_NOTIFY: 2895 case WM_NOTIFY:
2887 case WM_MOUSEMOVE: 2896 case WM_MOUSEMOVE:
2888 _wndproc(hWnd, msg, mp1, mp2); 2897 _wndproc(hWnd, msg, mp1, mp2);
2889 break; 2898 break;
2890 case WM_PAINT: 2899 case WM_PAINT:
2891 if(cinfo->cinfo.pOldProc && (cinfo->even != DW_RGB_TRANSPARENT || cinfo->odd != DW_RGB_TRANSPARENT)) 2900 if(continfo->cinfo.pOldProc && (continfo->even != DW_RGB_TRANSPARENT || continfo->odd != DW_RGB_TRANSPARENT))
2892 { 2901 {
2893 RECT rectUpd, rectDestin, rect; 2902 RECT rectUpd, rectDestin, rect;
2894 int iItems, iTop, i; 2903 int iItems, iTop, i;
2895 COLORREF c; 2904 COLORREF c;
2896 2905
2897 /* Load the default background color for the first pass */ 2906 /* Load the default background color for the first pass */
2898 ListView_SetTextBkColor(hWnd, cinfo->cinfo.back != -1 ? cinfo->cinfo.back : ListView_GetBkColor(hWnd)); 2907 ListView_SetTextBkColor(hWnd, continfo->cinfo.back != -1 ? continfo->cinfo.back : ListView_GetBkColor(hWnd));
2899 /* get the rectangle to be updated */ 2908 /* get the rectangle to be updated */
2900 GetUpdateRect(hWnd, &rectUpd, FALSE); 2909 GetUpdateRect(hWnd, &rectUpd, FALSE);
2901 /* allow default processing first */ 2910 /* allow default processing first */
2902 CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, 0, 0); 2911 CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0);
2903 /* number of displayed rows */ 2912 /* number of displayed rows */
2904 iItems = ListView_GetCountPerPage(hWnd); 2913 iItems = ListView_GetCountPerPage(hWnd);
2905 /* first visible row */ 2914 /* first visible row */
2906 iTop = ListView_GetTopIndex(hWnd); 2915 iTop = ListView_GetTopIndex(hWnd);
2907 2916
2909 { 2918 {
2910 /* if row rectangle intersects update rectangle then it requires re-drawing */ 2919 /* if row rectangle intersects update rectangle then it requires re-drawing */
2911 if(ListView_GetItemRect(hWnd, i, &rect, LVIR_BOUNDS) && IntersectRect(&rectDestin, &rectUpd, &rect)) 2920 if(ListView_GetItemRect(hWnd, i, &rect, LVIR_BOUNDS) && IntersectRect(&rectDestin, &rectUpd, &rect))
2912 { 2921 {
2913 /* change text background colour accordingly */ 2922 /* change text background colour accordingly */
2914 c = (i % 2) ? cinfo->odd : cinfo->even; 2923 c = (i % 2) ? continfo->odd : continfo->even;
2915 2924
2916 if(c != DW_RGB_TRANSPARENT) 2925 if(c != DW_RGB_TRANSPARENT)
2917 { 2926 {
2918 ListView_SetTextBkColor(hWnd, c); 2927 ListView_SetTextBkColor(hWnd, c);
2919 /* invalidate the row rectangle then... */ 2928 /* invalidate the row rectangle then... */
2920 InvalidateRect(hWnd, &rectDestin, FALSE); 2929 InvalidateRect(hWnd, &rectDestin, FALSE);
2921 /* ...force default processing */ 2930 /* ...force default processing */
2922 CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, 0, 0); 2931 CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, 0, 0);
2923 } 2932 }
2924 } 2933 }
2925 } 2934 }
2926 } 2935 }
2927 break; 2936 break;
3023 } 3032 }
3024 } 3033 }
3025 break; 3034 break;
3026 } 3035 }
3027 3036
3028 if(!cinfo || !cinfo->cinfo.pOldProc) 3037 if(!continfo || !continfo->cinfo.pOldProc)
3029 return DefWindowProc(hWnd, msg, mp1, mp2); 3038 return DefWindowProc(hWnd, msg, mp1, mp2);
3030 return CallWindowProc(cinfo->cinfo.pOldProc, hWnd, msg, mp1, mp2); 3039 return CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
3031 } 3040 }
3032 3041
3033 BOOL CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) 3042 BOOL CALLBACK _treewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
3034 { 3043 {
3035 ContainerInfo *cinfo; 3044 ContainerInfo *cinfo;
3373 */ 3382 */
3374 3383
3375 BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2) 3384 BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
3376 { 3385 {
3377 BubbleButton *bubble; 3386 BubbleButton *bubble;
3378 POINT point;
3379 RECT rect;
3380 WNDPROC pOldProc; 3387 WNDPROC pOldProc;
3381 3388
3382 bubble = (BubbleButton *)GetWindowLongPtr(hwnd, GWLP_USERDATA); 3389 bubble = (BubbleButton *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
3383 3390
3384 if ( !bubble ) 3391 if ( !bubble )
3627 int API dw_init(int newthread, int argc, char *argv[]) 3634 int API dw_init(int newthread, int argc, char *argv[])
3628 { 3635 {
3629 WNDCLASS wc; 3636 WNDCLASS wc;
3630 int z; 3637 int z;
3631 INITCOMMONCONTROLSEX icc; 3638 INITCOMMONCONTROLSEX icc;
3632 char *fname, *alttmpdir; 3639 char *alttmpdir;
3633 HFONT oldfont;
3634 #ifdef GDIPLUS 3640 #ifdef GDIPLUS
3635 struct GdiplusStartupInput si; 3641 struct GdiplusStartupInput si;
3636 #endif 3642 #endif
3637 3643
3638 /* Initialize our thread local storage */ 3644 /* Initialize our thread local storage */
3696 wc.lpszMenuName = NULL; 3702 wc.lpszMenuName = NULL;
3697 wc.lpszClassName = FRAMECLASSNAME; 3703 wc.lpszClassName = FRAMECLASSNAME;
3698 3704
3699 RegisterClass(&wc); 3705 RegisterClass(&wc);
3700 3706
3701 #ifdef BUILD_DLL 3707 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
3702 /* Register HTML renderer class */ 3708 /* Register HTML renderer class */
3703 memset(&wc, 0, sizeof(WNDCLASS)); 3709 memset(&wc, 0, sizeof(WNDCLASS));
3704 wc.lpfnWndProc = (WNDPROC)_browserWindowProc; 3710 wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
3705 wc.lpszClassName = BrowserClassName; 3711 wc.lpszClassName = BrowserClassName;
3706 wc.style = CS_HREDRAW|CS_VREDRAW; 3712 wc.style = CS_HREDRAW|CS_VREDRAW;
4725 * Parameters: 4731 * Parameters:
4726 * id: An ID to be used with dw_window_from_id or 0L. 4732 * id: An ID to be used with dw_window_from_id or 0L.
4727 */ 4733 */
4728 HWND API dw_html_new(unsigned long id) 4734 HWND API dw_html_new(unsigned long id)
4729 { 4735 {
4730 #if defined(BUILD_DLL) || defined(BUILD_HTML) 4736 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
4731 return CreateWindow(BrowserClassName, 4737 return CreateWindow(BrowserClassName,
4732 "", 4738 "",
4733 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, 4739 WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS,
4734 0,0,2000,1000, 4740 0,0,2000,1000,
4735 DW_HWND_OBJECT, 4741 DW_HWND_OBJECT,
4738 NULL); 4744 NULL);
4739 #else 4745 #else
4740 dw_debug("HTML widget not available; Support not enabled in this build.\n"); 4746 dw_debug("HTML widget not available; Support not enabled in this build.\n");
4741 return 0; 4747 return 0;
4742 #endif 4748 #endif
4749 }
4750
4751 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
4752 void _dw_html_action(HWND hwnd, int action);
4753 int _dw_html_raw(HWND hwnd, char *string);
4754 int _dw_html_url(HWND hwnd, char *url);
4755 #endif
4756
4757 /*
4758 * Causes the embedded HTML widget to take action.
4759 * Parameters:
4760 * handle: Handle to the window.
4761 * action: One of the DW_HTML_* constants.
4762 */
4763 void API dw_html_action(HWND handle, int action)
4764 {
4765 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
4766 _dw_html_action(handle, action);
4767 #endif
4768 }
4769
4770 /*
4771 * Render raw HTML code in the embedded HTML widget..
4772 * Parameters:
4773 * handle: Handle to the window.
4774 * string: String buffer containt HTML code to
4775 * be rendered.
4776 * Returns:
4777 * DW_ERROR_NONE (0) on success.
4778 */
4779 int API dw_html_raw(HWND handle, char *string)
4780 {
4781 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
4782 return _dw_html_raw(handle, string);
4783 #else
4784 return DW_ERROR_GENERAL;
4785 #endif
4786 }
4787
4788 /*
4789 * Render file or web page in the embedded HTML widget..
4790 * Parameters:
4791 * handle: Handle to the window.
4792 * url: Universal Resource Locator of the web or
4793 * file object to be rendered.
4794 * Returns:
4795 * DW_ERROR_NONE (0) on success.
4796 */
4797 int API dw_html_url(HWND handle, char *url)
4798 {
4799 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) && !defined(__MINGW32__)
4800 return _dw_html_url(handle, url);
4801 #else
4802 return DW_ERROR_GENERAL;
4803 #endif
4743 } 4804 }
4744 4805
4745 /* 4806 /*
4746 * Create a bitmap object to be packed. 4807 * Create a bitmap object to be packed.
4747 * Parameters: 4808 * Parameters:
5541 { 5602 {
5542 HWND tmp; 5603 HWND tmp;
5543 BubbleButton *bubble; 5604 BubbleButton *bubble;
5544 HBITMAP hbitmap = 0; 5605 HBITMAP hbitmap = 0;
5545 HANDLE hicon = 0; 5606 HANDLE hicon = 0;
5546 int windowtype = 0, len; 5607 int windowtype = 0;
5547 5608
5548 if (!(bubble = calloc(1, sizeof(BubbleButton)))) 5609 if (!(bubble = calloc(1, sizeof(BubbleButton))))
5549 return 0; 5610 return 0;
5550 5611
5551 #ifdef GDIPLUS 5612 #ifdef GDIPLUS
5602 BubbleButton *bubble; 5663 BubbleButton *bubble;
5603 HBITMAP hbitmap = 0; 5664 HBITMAP hbitmap = 0;
5604 HANDLE hicon = 0; 5665 HANDLE hicon = 0;
5605 char *file; 5666 char *file;
5606 FILE *fp; 5667 FILE *fp;
5607 int windowtype; 5668 int windowtype = BS_BITMAP;
5608 5669
5609 if ( !(bubble = calloc(1, sizeof(BubbleButton))) ) 5670 if ( !(bubble = calloc(1, sizeof(BubbleButton))) )
5610 return 0; 5671 return 0;
5611 file = _tempnam( _dw_alternate_temp_dir, "dw" ); 5672 file = _tempnam( _dw_alternate_temp_dir, "dw" );
5612 if ( file != NULL ) 5673 if ( file != NULL )
5618 fclose( fp ); 5679 fclose( fp );
5619 #ifdef GDIPLUS 5680 #ifdef GDIPLUS
5620 if((hicon = _dw_load_icon(file))) 5681 if((hicon = _dw_load_icon(file)))
5621 windowtype = BS_ICON; 5682 windowtype = BS_ICON;
5622 else 5683 else
5623 {
5624 hbitmap = _dw_load_bitmap(file, NULL); 5684 hbitmap = _dw_load_bitmap(file, NULL);
5625 windowtype = BS_BITMAP;
5626 }
5627 #else 5685 #else
5628 if ( len > 1 && data[0] == 'B' && data[1] == 'M' ) /* first 2 chars of data is BM, then its a BMP */ 5686 if ( len > 1 && data[0] == 'B' && data[1] == 'M' ) /* first 2 chars of data is BM, then its a BMP */
5629 {
5630 hbitmap = (HBITMAP)LoadImage( NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); 5687 hbitmap = (HBITMAP)LoadImage( NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
5631 windowtype = BS_BITMAP;
5632 }
5633 else /* otherwise its assumed to be an ico */ 5688 else /* otherwise its assumed to be an ico */
5634 { 5689 {
5635 hicon = LoadImage( NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); 5690 hicon = LoadImage( NULL, file, IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
5636 windowtype = BS_ICON; 5691 windowtype = BS_ICON;
5637 } 5692 }
5919 * Windows and a pixmap on Unix, pass 5974 * Windows and a pixmap on Unix, pass
5920 * NULL if you use the id param) 5975 * NULL if you use the id param)
5921 */ 5976 */
5922 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) 5977 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
5923 { 5978 {
5924 HBITMAP hbitmap; 5979 HBITMAP hbitmap = 0;
5925 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); 5980 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
5926 HICON icon = 0; 5981 HANDLE icon = 0;
5927 HICON oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0); 5982 HANDLE oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
5928 5983
5929 if(id) 5984 if(id)
5930 { 5985 {
5931 hbitmap = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_SHARED); 5986 hbitmap = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS | LR_SHARED);
5932 icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_SHARED); 5987 icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_SHARED);
6591 6646
6592 for(z=0;z<256;z++) 6647 for(z=0;z<256;z++)
6593 { 6648 {
6594 if(!array[z]) 6649 if(!array[z])
6595 { 6650 {
6596 int oldpage = TabCtrl_GetCurSel(handle);
6597
6598 array[z] = calloc(1, sizeof(NotebookPage)); 6651 array[z] = calloc(1, sizeof(NotebookPage));
6599 array[z]->realid = refid; 6652 array[z]->realid = refid;
6600 array[z]->item.mask = TCIF_TEXT; 6653 array[z]->item.mask = TCIF_TEXT;
6601 array[z]->item.iImage = -1; 6654 array[z]->item.iImage = -1;
6602 array[z]->item.pszText = ""; 6655 array[z]->item.pszText = "";
7940 * DW pick the appropriate file extension. 7993 * DW pick the appropriate file extension.
7941 * (ICO on OS/2 or Windows, XPM on Unix) 7994 * (ICO on OS/2 or Windows, XPM on Unix)
7942 */ 7995 */
7943 HICN API dw_icon_load_from_data(char *data, int len) 7996 HICN API dw_icon_load_from_data(char *data, int len)
7944 { 7997 {
7945 HANDLE icon; 7998 HANDLE icon = 0;
7946 char *file; 7999 char *file;
7947 FILE *fp; 8000 FILE *fp;
7948 8001
7949 if ( !data ) 8002 if ( !data )
7950 return 0; 8003 return 0;
8864 void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y) 8917 void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
8865 { 8918 {
8866 HDC hdcPaint; 8919 HDC hdcPaint;
8867 HBRUSH oldBrush; 8920 HBRUSH oldBrush;
8868 HPEN oldPen; 8921 HPEN oldPen;
8869 POINT *points; 8922 POINT *points = NULL;
8870 int i; 8923 int i;
8871 8924
8872 if ( handle ) 8925 if ( handle )
8873 hdcPaint = GetDC( handle ); 8926 hdcPaint = GetDC( handle );
8874 else if ( pixmap ) 8927 else if ( pixmap )
8899 points[npoints].y = points[0].y; 8952 points[npoints].y = points[0].y;
8900 /* ... and increment the number of points */ 8953 /* ... and increment the number of points */
8901 npoints++; 8954 npoints++;
8902 } 8955 }
8903 } 8956 }
8957 else
8958 return;
8904 8959
8905 oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) ); 8960 oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
8906 oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) ); 8961 oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
8907 if ( flags & DW_DRAW_FILL ) 8962 if ( flags & DW_DRAW_FILL )
8908 Polygon( hdcPaint, points, npoints ); 8963 Polygon( hdcPaint, points, npoints );
9124 */ 9179 */
9125 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth) 9180 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
9126 { 9181 {
9127 HPIXMAP pixmap; 9182 HPIXMAP pixmap;
9128 HDC hdc; 9183 HDC hdc;
9129 COLORREF bkcolor;
9130 ULONG cx, cy;
9131 9184
9132 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 9185 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
9133 return NULL; 9186 return NULL;
9134 9187
9135 hdc = GetDC(handle); 9188 hdc = GetDC(handle);
9212 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) 9265 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename)
9213 { 9266 {
9214 HPIXMAP pixmap; 9267 HPIXMAP pixmap;
9215 BITMAP bm; 9268 BITMAP bm;
9216 HDC hdc; 9269 HDC hdc;
9217 ULONG cx, cy;
9218 BITMAPINFO *info;
9219 #ifndef GDIPLUS 9270 #ifndef GDIPLUS
9220 char *file; 9271 char *file;
9221 #endif 9272 #endif
9222 9273
9223 if (!filename || !(pixmap = calloc(1,sizeof(struct _hpixmap)))) 9274 if (!filename || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
9281 HPIXMAP pixmap; 9332 HPIXMAP pixmap;
9282 BITMAP bm; 9333 BITMAP bm;
9283 HDC hdc; 9334 HDC hdc;
9284 char *file; 9335 char *file;
9285 FILE *fp; 9336 FILE *fp;
9286 ULONG cx, cy;
9287 9337
9288 if ( !(pixmap = calloc(1,sizeof(struct _hpixmap))) ) 9338 if ( !(pixmap = calloc(1,sizeof(struct _hpixmap))) )
9289 { 9339 {
9290 return NULL; 9340 return NULL;
9291 } 9341 }
10162 * None. 10212 * None.
10163 * Returns: 10213 * Returns:
10164 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not 10214 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
10165 * be converted to text. 10215 * be converted to text.
10166 */ 10216 */
10167 char *dw_clipboard_get_text() 10217 char * API dw_clipboard_get_text(void)
10168 { 10218 {
10169 HANDLE handle; 10219 HANDLE handle;
10170 char *tmp, *ret = NULL; 10220 char *tmp, *ret = NULL;
10171 10221
10172 if ( !OpenClipboard( NULL ) ) 10222 if ( !OpenClipboard( NULL ) )
10190 /* 10240 /*
10191 * Sets the contents of the default clipboard to the supplied text. 10241 * Sets the contents of the default clipboard to the supplied text.
10192 * Parameters: 10242 * Parameters:
10193 * Text. 10243 * Text.
10194 */ 10244 */
10195 void dw_clipboard_set_text( char *str, int len ) 10245 void API dw_clipboard_set_text( char *str, int len )
10196 { 10246 {
10197 HGLOBAL ptr1; 10247 HGLOBAL ptr1;
10198 LPTSTR ptr2; 10248 LPTSTR ptr2;
10199 10249
10200 if ( !OpenClipboard( NULL ) ) 10250 if ( !OpenClipboard( NULL ) )
10303 OPENFILENAME of; 10353 OPENFILENAME of;
10304 char filenamebuf[1001] = {0}; 10354 char filenamebuf[1001] = {0};
10305 char filterbuf[1001] = {0}; 10355 char filterbuf[1001] = {0};
10306 int rc; 10356 int rc;
10307 10357
10308 BROWSEINFO bi;
10309 TCHAR szDir[MAX_PATH];
10310 LPITEMIDLIST pidl;
10311 LPMALLOC pMalloc;
10312
10313 if ( flags == DW_DIRECTORY_OPEN ) 10358 if ( flags == DW_DIRECTORY_OPEN )
10314 { 10359 {
10315 /* If we aren't building a DLL, use the more simple browser */ 10360 /* If we aren't building a DLL, use the more simple browser */
10316 #ifndef BUILD_DLL 10361 #ifndef BUILD_DLL
10362 BROWSEINFO bi;
10363 TCHAR szDir[MAX_PATH];
10364 LPITEMIDLIST pidl;
10365 LPMALLOC pMalloc;
10366
10317 if (SUCCEEDED(SHGetMalloc(&pMalloc))) 10367 if (SUCCEEDED(SHGetMalloc(&pMalloc)))
10318 { 10368 {
10319 ZeroMemory(&bi,sizeof(bi)); 10369 ZeroMemory(&bi,sizeof(bi));
10320 bi.hwndOwner = NULL; 10370 bi.hwndOwner = NULL;
10321 bi.pszDisplayName = 0; 10371 bi.pszDisplayName = 0;
10436 strcat(newparams[z], params[z]); 10486 strcat(newparams[z], params[z]);
10437 strcat(newparams[z], "\""); 10487 strcat(newparams[z], "\"");
10438 } 10488 }
10439 newparams[count] = NULL; 10489 newparams[count] = NULL;
10440 10490
10441 retcode = spawnvp(P_NOWAIT, program, newparams); 10491 retcode = _spawnvp(P_NOWAIT, program, (const char * const *)newparams);
10442 10492
10443 for(z=0;z<count;z++) 10493 for(z=0;z<count;z++)
10444 { 10494 {
10445 free(newparams[z]); 10495 free(newparams[z]);
10446 } 10496 }