comparison win/dw.c @ 2034:89d62197124b

Visual C in C++ mode complains about missing const declarations in paramaters. So adding const to any string parameters which are not written to. Probably going to require changes to the other platforms due to header changes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 17 Nov 2019 03:13:37 +0000
parents 28809bf17957
children ea303d356419
comparison
equal deleted inserted replaced
2033:d81d2ea806c6 2034:89d62197124b
318 #endif 318 #endif
319 LRESULT CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); 319 LRESULT CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2);
320 void _resize_notebook_page(HWND handle, int pageid); 320 void _resize_notebook_page(HWND handle, int pageid);
321 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); 321 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y);
322 int _lookup_icon(HWND handle, HICON hicon, int type); 322 int _lookup_icon(HWND handle, HICON hicon, int type);
323 HFONT _acquire_font(HWND handle, char *fontname); 323 HFONT _acquire_font(HWND handle, const char *fontname);
324 void _click_default(HWND handle); 324 void _click_default(HWND handle);
325 void _do_resize(Box *thisbox, int x, int y); 325 void _do_resize(Box *thisbox, int x, int y);
326 326
327 /* Internal function to queue a window redraw */ 327 /* Internal function to queue a window redraw */
328 void _dw_redraw(HWND window, int skip) 328 void _dw_redraw(HWND window, int skip)
493 #endif 493 #endif
494 494
495 #ifdef UNICODE 495 #ifdef UNICODE
496 /* Macro and internal function to convert UTF8 to Unicode wide characters */ 496 /* Macro and internal function to convert UTF8 to Unicode wide characters */
497 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) 497 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
498 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf) 498 LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf)
499 { 499 {
500 LPWSTR retbuf = outbuf; 500 LPWSTR retbuf = outbuf;
501 501
502 if(retbuf) 502 if(retbuf)
503 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)); 503 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR));
504 return retbuf; 504 return retbuf;
505 } 505 }
506 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL) 506 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
507 char *_myWideToUTF8(LPWSTR widestring, void *outbuf) 507 char *_myWideToUTF8(LPCWSTR widestring, void *outbuf)
508 { 508 {
509 char *retbuf = outbuf; 509 char *retbuf = outbuf;
510 510
511 if(retbuf) 511 if(retbuf)
512 WideCharToMultiByte(CP_UTF8, 0, widestring, -1, retbuf, WideCharToMultiByte(CP_UTF8, 0, widestring, -1, NULL, 0, NULL, NULL), NULL, NULL); 512 WideCharToMultiByte(CP_UTF8, 0, widestring, -1, retbuf, WideCharToMultiByte(CP_UTF8, 0, widestring, -1, NULL, 0, NULL, NULL), NULL, NULL);
575 ".tiff", 575 ".tiff",
576 ".bmp" 576 ".bmp"
577 }; 577 };
578 578
579 /* Section for loading files of types besides BMP and ICO and return HBITMAP or HICON */ 579 /* Section for loading files of types besides BMP and ICO and return HBITMAP or HICON */
580 void *_dw_load_gpbitmap( char *filename ) 580 void *_dw_load_gpbitmap(const char *filename)
581 { 581 {
582 int i, wclen = (int)(strlen(filename) + 6) * sizeof(wchar_t); 582 int i, wclen = (int)(strlen(filename) + 6) * sizeof(wchar_t);
583 char *file = _alloca(strlen(filename) + 6); 583 char *file = _alloca(strlen(filename) + 6);
584 wchar_t *wfile = _alloca(wclen); 584 wchar_t *wfile = _alloca(wclen);
585 void *image; 585 void *image;
599 } 599 }
600 return NULL; 600 return NULL;
601 } 601 }
602 602
603 /* Try to load the appropriate image and return the HBITMAP handle */ 603 /* Try to load the appropriate image and return the HBITMAP handle */
604 HBITMAP _dw_load_bitmap(char *filename, unsigned long *depth) 604 HBITMAP _dw_load_bitmap(const char *filename, unsigned long *depth)
605 { 605 {
606 void *bitmap = _dw_load_gpbitmap(filename); 606 void *bitmap = _dw_load_gpbitmap(filename);
607 if(bitmap) 607 if(bitmap)
608 { 608 {
609 HBITMAP hbm = NULL; 609 HBITMAP hbm = NULL;
662 } 662 }
663 return NULL; 663 return NULL;
664 } 664 }
665 665
666 /* Try to load the appropriate image and return the HICON handle */ 666 /* Try to load the appropriate image and return the HICON handle */
667 HICON _dw_load_icon(char *filename) 667 HICON _dw_load_icon(const char *filename)
668 { 668 {
669 void *bitmap = _dw_load_gpbitmap(filename); 669 void *bitmap = _dw_load_gpbitmap(filename);
670 if(bitmap) 670 if(bitmap)
671 { 671 {
672 HICON hicon = NULL; 672 HICON hicon = NULL;
927 Root = new; 927 Root = new;
928 } 928 }
929 } 929 }
930 930
931 /* Finds the message number for a given signal name */ 931 /* Finds the message number for a given signal name */
932 ULONG _findsigmessage(char *signame) 932 ULONG _findsigmessage(const char *signame)
933 { 933 {
934 int z; 934 int z;
935 935
936 for(z=0;z<SIGNALMAX;z++) 936 for(z=0;z<SIGNALMAX;z++)
937 { 937 {
4070 4070
4071 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL); 4071 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
4072 } 4072 }
4073 } 4073 }
4074 4074
4075 void _create_tooltip(HWND handle, char *text) 4075 void _create_tooltip(HWND handle, const char *text)
4076 { 4076 {
4077 TOOLINFO ti = { 0 }; 4077 TOOLINFO ti = { 0 };
4078 4078
4079 ti.cbSize = sizeof(TOOLINFO); 4079 ti.cbSize = sizeof(TOOLINFO);
4080 ti.hwnd = handle; 4080 ti.hwnd = handle;
4350 #ifdef BUILD_EDGE 4350 #ifdef BUILD_EDGE
4351 /* Check if Microsoft Edge (Chromium) is installed */ 4351 /* Check if Microsoft Edge (Chromium) is installed */
4352 if (_DW_EDGE_DETECTED = _dw_edge_detect()) 4352 if (_DW_EDGE_DETECTED = _dw_edge_detect())
4353 { 4353 {
4354 wc.lpfnWndProc = (WNDPROC)_edgeWindowProc; 4354 wc.lpfnWndProc = (WNDPROC)_edgeWindowProc;
4355 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
4355 } 4356 }
4356 else 4357 else
4357 #endif 4358 #endif
4358 { 4359 {
4359 wc.lpfnWndProc = (WNDPROC)_browserWindowProc; 4360 wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
4577 * Displays a debug message on the console... 4578 * Displays a debug message on the console...
4578 * Parameters: 4579 * Parameters:
4579 * format: printf style format string. 4580 * format: printf style format string.
4580 * ...: Additional variables for use in the format. 4581 * ...: Additional variables for use in the format.
4581 */ 4582 */
4582 void API dw_debug(char *format, ...) 4583 void API dw_debug(const char *format, ...)
4583 { 4584 {
4584 va_list args; 4585 va_list args;
4585 char outbuf[1025] = {0}, *thisbuf = outbuf; 4586 char outbuf[1025] = {0}, *thisbuf = outbuf;
4586 4587
4587 va_start(args, format); 4588 va_start(args, format);
4596 * Parameters: 4597 * Parameters:
4597 * title: The title of the message box. 4598 * title: The title of the message box.
4598 * format: printf style format string. 4599 * format: printf style format string.
4599 * ...: Additional variables for use in the format. 4600 * ...: Additional variables for use in the format.
4600 */ 4601 */
4601 int API dw_messagebox(char *title, int flags, char *format, ...) 4602 int API dw_messagebox(const char *title, int flags, const char *format, ...)
4602 { 4603 {
4603 va_list args; 4604 va_list args;
4604 char outbuf[1025] = { 0 }, *thisbuf = outbuf; 4605 char outbuf[1025] = { 0 }, *thisbuf = outbuf;
4605 int rc; 4606 int rc;
4606 4607
4763 void API dw_window_reparent(HWND handle, HWND newparent) 4764 void API dw_window_reparent(HWND handle, HWND newparent)
4764 { 4765 {
4765 SetParent(handle, newparent); 4766 SetParent(handle, newparent);
4766 } 4767 }
4767 4768
4768 LOGFONT _get_logfont(HDC hdc, char *fontname) 4769 LOGFONT _get_logfont(HDC hdc, const char *fontname)
4769 { 4770 {
4770 char *Italic, *Bold, *myFontName = strchr(fontname, '.'); 4771 char *Italic, *Bold, *myFontName = strchr(fontname, '.');
4771 int size = atoi(fontname); 4772 int size = atoi(fontname);
4772 LOGFONT lf = {0}; 4773 LOGFONT lf = {0};
4773 4774
4811 } 4812 }
4812 4813
4813 /* Create a font handle from specified font name.. 4814 /* Create a font handle from specified font name..
4814 * or return a handle to the default font. 4815 * or return a handle to the default font.
4815 */ 4816 */
4816 HFONT _acquire_font2(HDC hdc, char *fontname) 4817 HFONT _acquire_font2(HDC hdc, const char *fontname)
4817 { 4818 {
4818 HFONT hfont = 0; 4819 HFONT hfont = 0;
4819 4820
4820 if(fontname != DefaultFont && fontname[0]) 4821 if(fontname != DefaultFont && fontname[0])
4821 { 4822 {
4830 } 4831 }
4831 4832
4832 /* Create a font handle from specified font name.. 4833 /* Create a font handle from specified font name..
4833 * or return a handle to the default font. 4834 * or return a handle to the default font.
4834 */ 4835 */
4835 HFONT _acquire_font(HWND handle, char *fontname) 4836 HFONT _acquire_font(HWND handle, const char *fontname)
4836 { 4837 {
4837 HDC hdc = GetDC(handle); 4838 HDC hdc = GetDC(handle);
4838 HFONT hfont = _acquire_font2(hdc, fontname); 4839 HFONT hfont = _acquire_font2(hdc, fontname);
4839 ReleaseDC(handle, hdc); 4840 ReleaseDC(handle, hdc);
4840 return hfont; 4841 return hfont;
4843 /* 4844 /*
4844 * Sets the default font used on text based widgets. 4845 * Sets the default font used on text based widgets.
4845 * Parameters: 4846 * Parameters:
4846 * fontname: Font name in Dynamic Windows format. 4847 * fontname: Font name in Dynamic Windows format.
4847 */ 4848 */
4848 void API dw_font_set_default(char *fontname) 4849 void API dw_font_set_default(const char *fontname)
4849 { 4850 {
4850 HFONT oldfont = _DefaultFont; 4851 HFONT oldfont = _DefaultFont;
4851 4852
4852 _DefaultFont = _acquire_font(HWND_DESKTOP, fontname); 4853 _DefaultFont = _acquire_font(HWND_DESKTOP, fontname);
4853 if(oldfont) 4854 if(oldfont)
5185 * Sets the font used by a specified window (widget) handle. 5186 * Sets the font used by a specified window (widget) handle.
5186 * Parameters: 5187 * Parameters:
5187 * handle: The window (widget) handle. 5188 * handle: The window (widget) handle.
5188 * fontname: Name and size of the font in the form "size.fontname" 5189 * fontname: Name and size of the font in the form "size.fontname"
5189 */ 5190 */
5190 int API dw_window_set_font(HWND handle, char *fontname) 5191 int API dw_window_set_font(HWND handle, const char *fontname)
5191 { 5192 {
5192 HFONT hfont, oldfont; 5193 HFONT hfont, oldfont;
5193 ColorInfo *cinfo; 5194 ColorInfo *cinfo;
5194 TCHAR tmpbuf[100] = {0}; 5195 TCHAR tmpbuf[100] = {0};
5195 5196
5254 * Parameters: 5255 * Parameters:
5255 * currfont: current font 5256 * currfont: current font
5256 * Returns: 5257 * Returns:
5257 * A malloced buffer with the selected font or NULL on error. 5258 * A malloced buffer with the selected font or NULL on error.
5258 */ 5259 */
5259 char * API dw_font_choose(char *currfont) 5260 char * API dw_font_choose(const char *currfont)
5260 { 5261 {
5261 CHOOSEFONT cf = { 0 }; 5262 CHOOSEFONT cf = { 0 };
5262 LOGFONT lf = { 0 }; 5263 LOGFONT lf = { 0 };
5263 char *str = NULL; 5264 char *str = NULL;
5264 char *bold = ""; 5265 char *bold = "";
5455 * Parameters: 5456 * Parameters:
5456 * owner: The Owner's window handle or HWND_DESKTOP. 5457 * owner: The Owner's window handle or HWND_DESKTOP.
5457 * title: The Window title. 5458 * title: The Window title.
5458 * flStyle: Style flags, see the DW reference. 5459 * flStyle: Style flags, see the DW reference.
5459 */ 5460 */
5460 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 5461 HWND API dw_window_new(HWND hwndOwner, const char *title, ULONG flStyle)
5461 { 5462 {
5462 HWND hwndframe; 5463 HWND hwndframe;
5463 Box *newbox = calloc(sizeof(Box), 1); 5464 Box *newbox = calloc(sizeof(Box), 1);
5464 ULONG flStyleEx = 0; 5465 ULONG flStyleEx = 0;
5465 #ifdef AEROGLASS 5466 #ifdef AEROGLASS
5628 * Parameters: 5629 * Parameters:
5629 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 5630 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
5630 * pad: Number of pixels to pad around the box. 5631 * pad: Number of pixels to pad around the box.
5631 * title: Text to be displayined in the group outline. 5632 * title: Text to be displayined in the group outline.
5632 */ 5633 */
5633 HWND API dw_groupbox_new(int type, int pad, char *title) 5634 HWND API dw_groupbox_new(int type, int pad, const char *title)
5634 { 5635 {
5635 Box *newbox = calloc(sizeof(Box), 1); 5636 Box *newbox = calloc(sizeof(Box), 1);
5636 HWND hwndframe; 5637 HWND hwndframe;
5637 5638
5638 newbox->pad = pad; 5639 newbox->pad = pad;
5715 #endif 5716 #endif
5716 } 5717 }
5717 5718
5718 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 5719 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
5719 void _dw_html_action(HWND hwnd, int action); 5720 void _dw_html_action(HWND hwnd, int action);
5720 int _dw_html_raw(HWND hwnd, char *string); 5721 int _dw_html_raw(HWND hwnd, const char *string);
5721 int _dw_html_url(HWND hwnd, char *url); 5722 int _dw_html_url(HWND hwnd, const char *url);
5722 int _dw_html_javascript_run(HWND hwnd, char *script, void *scriptdata); 5723 int _dw_html_javascript_run(HWND hwnd, const char *script, void *scriptdata);
5723 #ifdef BUILD_EDGE 5724 #ifdef BUILD_EDGE
5724 void _dw_edge_action(HWND hwnd, int action); 5725 void _dw_edge_action(HWND hwnd, int action);
5725 int _dw_edge_raw(HWND hwnd, char *string); 5726 int _dw_edge_raw(HWND hwnd, const char *string);
5726 int _dw_edge_url(HWND hwnd, char *url); 5727 int _dw_edge_url(HWND hwnd, const char *url);
5727 int _dw_edge_javascript_run(HWND hwnd, char *script, void *scriptdata); 5728 int _dw_edge_javascript_run(HWND hwnd, const char *script, void *scriptdata);
5728 #endif 5729 #endif
5729 #endif 5730 #endif
5730 5731
5731 /* 5732 /*
5732 * Causes the embedded HTML widget to take action. 5733 * Causes the embedded HTML widget to take action.
5753 * string: String buffer containt HTML code to 5754 * string: String buffer containt HTML code to
5754 * be rendered. 5755 * be rendered.
5755 * Returns: 5756 * Returns:
5756 * DW_ERROR_NONE (0) on success. 5757 * DW_ERROR_NONE (0) on success.
5757 */ 5758 */
5758 int API dw_html_raw(HWND handle, char *string) 5759 int API dw_html_raw(HWND handle, const char *string)
5759 { 5760 {
5760 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 5761 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
5761 #ifdef BUILD_EDGE 5762 #ifdef BUILD_EDGE
5762 if (_DW_EDGE_DETECTED) 5763 if (_DW_EDGE_DETECTED)
5763 return _dw_edge_raw(handle, string); 5764 return _dw_edge_raw(handle, string);
5775 * url: Universal Resource Locator of the web or 5776 * url: Universal Resource Locator of the web or
5776 * file object to be rendered. 5777 * file object to be rendered.
5777 * Returns: 5778 * Returns:
5778 * DW_ERROR_NONE (0) on success. 5779 * DW_ERROR_NONE (0) on success.
5779 */ 5780 */
5780 int API dw_html_url(HWND handle, char *url) 5781 int API dw_html_url(HWND handle, const char *url)
5781 { 5782 {
5782 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 5783 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
5783 #if BUILD_EDGE 5784 #if BUILD_EDGE
5784 if (_DW_EDGE_DETECTED) 5785 if (_DW_EDGE_DETECTED)
5785 return _dw_edge_url(handle, url); 5786 return _dw_edge_url(handle, url);
5798 * scriptdata: Data passed to the signal handler. 5799 * scriptdata: Data passed to the signal handler.
5799 * Notes: A DW_SIGNAL_HTML_RESULT event will be raised with scriptdata. 5800 * Notes: A DW_SIGNAL_HTML_RESULT event will be raised with scriptdata.
5800 * Returns: 5801 * Returns:
5801 * DW_ERROR_NONE (0) on success. 5802 * DW_ERROR_NONE (0) on success.
5802 */ 5803 */
5803 int dw_html_javascript_run(HWND handle, char *script, void *scriptdata) 5804 int dw_html_javascript_run(HWND handle, const char *script, void *scriptdata)
5804 { 5805 {
5805 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 5806 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
5806 #if BUILD_EDGE 5807 #if BUILD_EDGE
5807 if (_DW_EDGE_DETECTED) 5808 if (_DW_EDGE_DETECTED)
5808 return _dw_edge_javascript_run(handle, script, scriptdata); 5809 return _dw_edge_javascript_run(handle, script, scriptdata);
6353 * Create a new static text window (widget) to be packed. 6354 * Create a new static text window (widget) to be packed.
6354 * Parameters: 6355 * Parameters:
6355 * text: The text to be display by the static text widget. 6356 * text: The text to be display by the static text widget.
6356 * id: An ID to be used with dw_window_from_id() or 0L. 6357 * id: An ID to be used with dw_window_from_id() or 0L.
6357 */ 6358 */
6358 HWND API dw_text_new(char *text, ULONG id) 6359 HWND API dw_text_new(const char *text, ULONG id)
6359 { 6360 {
6360 HWND tmp = CreateWindow(STATICCLASSNAME, 6361 HWND tmp = CreateWindow(STATICCLASSNAME,
6361 UTF8toWide(text), 6362 UTF8toWide(text),
6362 SS_NOPREFIX | SS_NOTIFY | SS_LEFTNOWORDWRAP | 6363 SS_NOPREFIX | SS_NOTIFY | SS_LEFTNOWORDWRAP |
6363 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, 6364 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
6383 * Create a new status text window (widget) to be packed. 6384 * Create a new status text window (widget) to be packed.
6384 * Parameters: 6385 * Parameters:
6385 * text: The text to be display by the static text widget. 6386 * text: The text to be display by the static text widget.
6386 * id: An ID to be used with dw_window_from_id() or 0L. 6387 * id: An ID to be used with dw_window_from_id() or 0L.
6387 */ 6388 */
6388 HWND API dw_status_text_new(char *text, ULONG id) 6389 HWND API dw_status_text_new(const char *text, ULONG id)
6389 { 6390 {
6390 HWND tmp = CreateWindow(StatusbarClassName, 6391 HWND tmp = CreateWindow(StatusbarClassName,
6391 UTF8toWide(text), 6392 UTF8toWide(text),
6392 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, 6393 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
6393 0,0,0,0, 6394 0,0,0,0,
6469 * Create a new Entryfield passwird window (widget) to be packed. 6470 * Create a new Entryfield passwird window (widget) to be packed.
6470 * Parameters: 6471 * Parameters:
6471 * text: The default text to be in the entryfield widget. 6472 * text: The default text to be in the entryfield widget.
6472 * id: An ID to be used with dw_window_from_id() or 0L. 6473 * id: An ID to be used with dw_window_from_id() or 0L.
6473 */ 6474 */
6474 HWND API dw_entryfield_password_new(char *text, ULONG id) 6475 HWND API dw_entryfield_password_new(const char *text, ULONG id)
6475 { 6476 {
6476 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, 6477 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
6477 EDITCLASSNAME, 6478 EDITCLASSNAME,
6478 UTF8toWide(text), 6479 UTF8toWide(text),
6479 ES_WANTRETURN | WS_CHILD | 6480 ES_WANTRETURN | WS_CHILD |
6601 DeleteDC(hdc); 6602 DeleteDC(hdc);
6602 } 6603 }
6603 } 6604 }
6604 6605
6605 /* Internal function to create a toolbar based button */ 6606 /* Internal function to create a toolbar based button */
6606 HWND _create_toolbar(char *text, ULONG id, HICON icon, HBITMAP hbitmap) 6607 HWND _create_toolbar(const char *text, ULONG id, HICON icon, HBITMAP hbitmap)
6607 { 6608 {
6608 HWND tmp; 6609 HWND tmp;
6609 HIMAGELIST imlist, dimlist; 6610 HIMAGELIST imlist, dimlist;
6610 BITMAP bmi = { 0 }; 6611 BITMAP bmi = { 0 };
6611 TBBUTTON tbButtons[] = { 6612 TBBUTTON tbButtons[] = {
6666 * Create a new bitmap button window (widget) to be packed. 6667 * Create a new bitmap button window (widget) to be packed.
6667 * Parameters: 6668 * Parameters:
6668 * text: Bubble help text to be displayed. 6669 * text: Bubble help text to be displayed.
6669 * id: An ID of a bitmap in the resource file. 6670 * id: An ID of a bitmap in the resource file.
6670 */ 6671 */
6671 HWND API dw_bitmapbutton_new(char *text, ULONG id) 6672 HWND API dw_bitmapbutton_new(const char *text, ULONG id)
6672 { 6673 {
6673 HWND tmp; 6674 HWND tmp;
6674 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); 6675 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
6675 HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0); 6676 HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0);
6676 HBITMAP hbitmap = icon ? 0 : LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); 6677 HBITMAP hbitmap = icon ? 0 : LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
6720 * id: An ID to be used with dw_window_from_id() or 0L. 6721 * id: An ID to be used with dw_window_from_id() or 0L.
6721 * filename: Name of the file, omit extention to have 6722 * filename: Name of the file, omit extention to have
6722 * DW pick the appropriate file extension. 6723 * DW pick the appropriate file extension.
6723 * (BMP or ICO on OS/2 or Windows, XPM on Unix) 6724 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
6724 */ 6725 */
6725 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) 6726 HWND API dw_bitmapbutton_new_from_file(const char *text, unsigned long id, const char *filename)
6726 { 6727 {
6727 HWND tmp; 6728 HWND tmp;
6728 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); 6729 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
6729 HBITMAP hbitmap = 0; 6730 HBITMAP hbitmap = 0;
6730 HANDLE hicon = 0; 6731 HANDLE hicon = 0;
6788 * id: An ID to be used with dw_window_from_id() or 0L. 6789 * id: An ID to be used with dw_window_from_id() or 0L.
6789 * data: The contents of the image 6790 * data: The contents of the image
6790 * (BMP or ICO on OS/2 or Windows, XPM on Unix) 6791 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
6791 * len: length of str 6792 * len: length of str
6792 */ 6793 */
6793 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) 6794 HWND API dw_bitmapbutton_new_from_data(const char *text, unsigned long id, const char *data, int len)
6794 { 6795 {
6795 HWND tmp; 6796 HWND tmp;
6796 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); 6797 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
6797 HBITMAP hbitmap = 0; 6798 HBITMAP hbitmap = 0;
6798 HANDLE hicon = 0; 6799 HANDLE hicon = 0;
6878 * Create a new spinbutton window (widget) to be packed. 6879 * Create a new spinbutton window (widget) to be packed.
6879 * Parameters: 6880 * Parameters:
6880 * text: The text to be display by the static text widget. 6881 * text: The text to be display by the static text widget.
6881 * id: An ID to be used with dw_window_from_id() or 0L. 6882 * id: An ID to be used with dw_window_from_id() or 0L.
6882 */ 6883 */
6883 HWND API dw_spinbutton_new(char *text, ULONG id) 6884 HWND API dw_spinbutton_new(const char *text, ULONG id)
6884 { 6885 {
6885 HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE, 6886 HWND buddy = CreateWindowEx(WS_EX_CLIENTEDGE,
6886 EDITCLASSNAME, 6887 EDITCLASSNAME,
6887 UTF8toWide(text), 6888 UTF8toWide(text),
6888 WS_CHILD | WS_BORDER | WS_VISIBLE | 6889 WS_CHILD | WS_BORDER | WS_VISIBLE |
7207 * (pass 0 if you use the filename param) 7208 * (pass 0 if you use the filename param)
7208 * filename: a path to a file (Bitmap on OS/2 or 7209 * filename: a path to a file (Bitmap on OS/2 or
7209 * Windows and a pixmap on Unix, pass 7210 * Windows and a pixmap on Unix, pass
7210 * NULL if you use the id param) 7211 * NULL if you use the id param)
7211 */ 7212 */
7212 void API dw_window_set_bitmap(HWND handle, unsigned long id, char *filename) 7213 void API dw_window_set_bitmap(HWND handle, unsigned long id, const char *filename)
7213 { 7214 {
7214 HBITMAP hbitmap = 0; 7215 HBITMAP hbitmap = 0;
7215 HANDLE icon = 0; 7216 HANDLE icon = 0;
7216 7217
7217 if(id) 7218 if(id)
7240 * data: the image from meory 7241 * data: the image from meory
7241 * Bitmap on Windows and a pixmap on Unix, pass 7242 * Bitmap on Windows and a pixmap on Unix, pass
7242 * NULL if you use the id param) 7243 * NULL if you use the id param)
7243 * len: length of data 7244 * len: length of data
7244 */ 7245 */
7245 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len) 7246 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long id, const char *data, int len)
7246 { 7247 {
7247 HBITMAP hbitmap=0; 7248 HBITMAP hbitmap=0;
7248 HICON icon=0; 7249 HICON icon=0;
7249 char *file; 7250 char *file;
7250 FILE *fp; 7251 FILE *fp;
7294 * Sets the text used for a given window. 7295 * Sets the text used for a given window.
7295 * Parameters: 7296 * Parameters:
7296 * handle: Handle to the window. 7297 * handle: Handle to the window.
7297 * text: The text associsated with a given window. 7298 * text: The text associsated with a given window.
7298 */ 7299 */
7299 void API dw_window_set_text(HWND handle, char *text) 7300 void API dw_window_set_text(HWND handle, const char *text)
7300 { 7301 {
7301 Box *thisbox; 7302 Box *thisbox;
7302 TCHAR tmpbuf[100] = {0}, *wtext = UTF8toWide(text); 7303 TCHAR tmpbuf[100] = {0}, *wtext = UTF8toWide(text);
7303 7304
7304 GetClassName(handle, tmpbuf, 99); 7305 GetClassName(handle, tmpbuf, 99);
7351 * Sets the text used for a given window's floating bubble help. 7352 * Sets the text used for a given window's floating bubble help.
7352 * Parameters: 7353 * Parameters:
7353 * handle: Handle to the window (widget). 7354 * handle: Handle to the window (widget).
7354 * bubbletext: The text in the floating bubble tooltip. 7355 * bubbletext: The text in the floating bubble tooltip.
7355 */ 7356 */
7356 void API dw_window_set_tooltip(HWND handle, char *bubbletext) 7357 void API dw_window_set_tooltip(HWND handle, const char *bubbletext)
7357 { 7358 {
7358 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); 7359 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
7359 7360
7360 if(cinfo && cinfo->buddy) 7361 if(cinfo && cinfo->buddy)
7361 _create_tooltip(cinfo->buddy, bubbletext); 7362 _create_tooltip(cinfo->buddy, bubbletext);
8245 * Parameters: 8246 * Parameters:
8246 * handle: Notebook handle. 8247 * handle: Notebook handle.
8247 * pageid: Page ID of the tab to set. 8248 * pageid: Page ID of the tab to set.
8248 * text: Pointer to the text to set. 8249 * text: Pointer to the text to set.
8249 */ 8250 */
8250 void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text) 8251 void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, const char *text)
8251 { 8252 {
8252 8253
8253 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array"); 8254 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
8254 int pageid; 8255 int pageid;
8255 8256
8272 * Parameters: 8273 * Parameters:
8273 * handle: Notebook handle. 8274 * handle: Notebook handle.
8274 * pageid: Page ID of the tab to set. 8275 * pageid: Page ID of the tab to set.
8275 * text: Pointer to the text to set. 8276 * text: Pointer to the text to set.
8276 */ 8277 */
8277 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text) 8278 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, const char *text)
8278 { 8279 {
8279 } 8280 }
8280 8281
8281 /* 8282 /*
8282 * Packs the specified box into the notebook page. 8283 * Packs the specified box into the notebook page.
8414 * Appends the specified text to the listbox's (or combobox) entry list. 8415 * Appends the specified text to the listbox's (or combobox) entry list.
8415 * Parameters: 8416 * Parameters:
8416 * handle: Handle to the listbox to be appended to. 8417 * handle: Handle to the listbox to be appended to.
8417 * text: Text to append into listbox. 8418 * text: Text to append into listbox.
8418 */ 8419 */
8419 void API dw_listbox_append(HWND handle, char *text) 8420 void API dw_listbox_append(HWND handle, const char *text)
8420 { 8421 {
8421 TCHAR tmpbuf[100] = {0}; 8422 TCHAR tmpbuf[100] = {0};
8422 8423
8423 GetClassName(handle, tmpbuf, 99); 8424 GetClassName(handle, tmpbuf, 99);
8424 8425
8513 * Parameters: 8514 * Parameters:
8514 * handle: Handle to the listbox to be queried. 8515 * handle: Handle to the listbox to be queried.
8515 * index: Index into the list to be queried. 8516 * index: Index into the list to be queried.
8516 * buffer: Buffer where text will be copied. 8517 * buffer: Buffer where text will be copied.
8517 */ 8518 */
8518 void API dw_listbox_set_text(HWND handle, unsigned int index, char *buffer) 8519 void API dw_listbox_set_text(HWND handle, unsigned int index, const char *buffer)
8519 { 8520 {
8520 TCHAR tmpbuf[100] = {0}; 8521 TCHAR tmpbuf[100] = {0};
8521 8522
8522 GetClassName(handle, tmpbuf, 99); 8523 GetClassName(handle, tmpbuf, 99);
8523 8524
9192 * title: The text title of the entry. 9193 * title: The text title of the entry.
9193 * icon: Handle to coresponding icon. 9194 * icon: Handle to coresponding icon.
9194 * parent: Parent handle or 0 if root. 9195 * parent: Parent handle or 0 if root.
9195 * itemdata: Item specific data. 9196 * itemdata: Item specific data.
9196 */ 9197 */
9197 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, HICN icon, HTREEITEM parent, void *itemdata) 9198 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
9198 { 9199 {
9199 TVITEM tvi; 9200 TVITEM tvi;
9200 TVINSERTSTRUCT tvins; 9201 TVINSERTSTRUCT tvins;
9201 HTREEITEM hti; 9202 HTREEITEM hti;
9202 9203
9222 * title: The text title of the entry. 9223 * title: The text title of the entry.
9223 * icon: Handle to coresponding icon. 9224 * icon: Handle to coresponding icon.
9224 * parent: Parent handle or 0 if root. 9225 * parent: Parent handle or 0 if root.
9225 * itemdata: Item specific data. 9226 * itemdata: Item specific data.
9226 */ 9227 */
9227 HTREEITEM API dw_tree_insert(HWND handle, char *title, HICN icon, HTREEITEM parent, void *itemdata) 9228 HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
9228 { 9229 {
9229 TVITEM tvi; 9230 TVITEM tvi;
9230 TVINSERTSTRUCT tvins; 9231 TVINSERTSTRUCT tvins;
9231 HTREEITEM hti; 9232 HTREEITEM hti;
9232 9233
9251 * handle: Handle to the tree containing the item. 9252 * handle: Handle to the tree containing the item.
9252 * item: Handle of the item to be modified. 9253 * item: Handle of the item to be modified.
9253 * title: The text title of the entry. 9254 * title: The text title of the entry.
9254 * icon: Handle to coresponding icon. 9255 * icon: Handle to coresponding icon.
9255 */ 9256 */
9256 void API dw_tree_item_change(HWND handle, HTREEITEM item, char *title, HICN icon) 9257 void API dw_tree_item_change(HWND handle, HTREEITEM item, const char *title, HICN icon)
9257 { 9258 {
9258 TVITEM tvi; 9259 TVITEM tvi;
9259 9260
9260 tvi.mask = TVIF_HANDLE; 9261 tvi.mask = TVIF_HANDLE;
9261 tvi.hItem = item; 9262 tvi.hItem = item;
9453 * Configures the main filesystem column title for localization. 9454 * Configures the main filesystem column title for localization.
9454 * Parameters: 9455 * Parameters:
9455 * handle: Handle to the container to be configured. 9456 * handle: Handle to the container to be configured.
9456 * title: The title to be displayed in the main column. 9457 * title: The title to be displayed in the main column.
9457 */ 9458 */
9458 void API dw_filesystem_set_column_title(HWND handle, char *title) 9459 void API dw_filesystem_set_column_title(HWND handle, const char *title)
9459 { 9460 {
9460 char *newtitle = _strdup(title ? title : ""); 9461 char *newtitle = _strdup(title ? title : "");
9461 9462
9462 dw_window_set_data(handle, "_dw_coltitle", newtitle); 9463 dw_window_set_data(handle, "_dw_coltitle", newtitle);
9463 } 9464 }
9512 * Parameters: 9513 * Parameters:
9513 * filename: Name of the file, omit extention to have 9514 * filename: Name of the file, omit extention to have
9514 * DW pick the appropriate file extension. 9515 * DW pick the appropriate file extension.
9515 * (ICO on OS/2 or Windows, XPM on Unix) 9516 * (ICO on OS/2 or Windows, XPM on Unix)
9516 */ 9517 */
9517 HICN API dw_icon_load_from_file(char *filename) 9518 HICN API dw_icon_load_from_file(const char *filename)
9518 { 9519 {
9519 #ifdef GDIPLUS 9520 #ifdef GDIPLUS
9520 return _dw_load_icon(filename); 9521 return _dw_load_icon(filename);
9521 #else 9522 #else
9522 char *file = malloc(strlen(filename) + 5); 9523 char *file = malloc(strlen(filename) + 5);
9549 * Parameters: 9550 * Parameters:
9550 * data: Source of icon data 9551 * data: Source of icon data
9551 * DW pick the appropriate file extension. 9552 * DW pick the appropriate file extension.
9552 * (ICO on OS/2 or Windows, XPM on Unix) 9553 * (ICO on OS/2 or Windows, XPM on Unix)
9553 */ 9554 */
9554 HICN API dw_icon_load_from_data(char *data, int len) 9555 HICN API dw_icon_load_from_data(const char *data, int len)
9555 { 9556 {
9556 HANDLE icon = 0; 9557 HANDLE icon = 0;
9557 char *file; 9558 char *file;
9558 FILE *fp; 9559 FILE *fp;
9559 9560
9687 * pointer: Pointer to the allocated memory in dw_container_alloc(). 9688 * pointer: Pointer to the allocated memory in dw_container_alloc().
9688 * column: Zero based column of data being set. 9689 * column: Zero based column of data being set.
9689 * row: Zero based row of data being set. 9690 * row: Zero based row of data being set.
9690 * data: Pointer to the data to be added. 9691 * data: Pointer to the data to be added.
9691 */ 9692 */
9692 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, char *filename, HICN icon) 9693 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, const char *filename, HICN icon)
9693 { 9694 {
9694 LV_ITEM lvi; 9695 LV_ITEM lvi;
9695 int item = 0; 9696 int item = 0;
9696 9697
9697 if(pointer) 9698 if(pointer)
9858 * pointer: Pointer to the allocated memory in dw_container_alloc(). 9859 * pointer: Pointer to the allocated memory in dw_container_alloc().
9859 * column: Zero based column of data being set. 9860 * column: Zero based column of data being set.
9860 * row: Zero based row of data being set. 9861 * row: Zero based row of data being set.
9861 * data: Pointer to the data to be added. 9862 * data: Pointer to the data to be added.
9862 */ 9863 */
9863 void API dw_filesystem_change_file(HWND handle, int row, char *filename, HICN icon) 9864 void API dw_filesystem_change_file(HWND handle, int row, const char *filename, HICN icon)
9864 { 9865 {
9865 dw_filesystem_set_file(handle, NULL, row, filename, icon); 9866 dw_filesystem_set_file(handle, NULL, row, filename, icon);
9866 } 9867 }
9867 9868
9868 /* 9869 /*
9995 * Parameters: 9996 * Parameters:
9996 * pointer: Pointer to the allocated memory in dw_container_alloc(). 9997 * pointer: Pointer to the allocated memory in dw_container_alloc().
9997 * row: Zero based row of data being set. 9998 * row: Zero based row of data being set.
9998 * title: String title of the item. 9999 * title: String title of the item.
9999 */ 10000 */
10000 void API dw_container_set_row_title(void *pointer, int row, char *title) 10001 void API dw_container_set_row_title(void *pointer, int row, const char *title)
10001 { 10002 {
10002 _dw_container_set_row_data(pointer, pointer, row, _DW_DATA_TYPE_STRING, title); 10003 _dw_container_set_row_data(pointer, pointer, row, _DW_DATA_TYPE_STRING, (void *)title);
10003 } 10004 }
10004 10005
10005 /* 10006 /*
10006 * Changes the title of a row already inserted in the container. 10007 * Changes the title of a row already inserted in the container.
10007 * Parameters: 10008 * Parameters:
10008 * handle: Handle to the container window (widget). 10009 * handle: Handle to the container window (widget).
10009 * row: Zero based row of data being set. 10010 * row: Zero based row of data being set.
10010 * title: String title of the item. 10011 * title: String title of the item.
10011 */ 10012 */
10012 void API dw_container_change_row_title(HWND handle, int row, char *title) 10013 void API dw_container_change_row_title(HWND handle, int row, const char *title)
10013 { 10014 {
10014 _dw_container_set_row_data(handle, NULL, row, _DW_DATA_TYPE_STRING, title); 10015 _dw_container_set_row_data(handle, NULL, row, _DW_DATA_TYPE_STRING, (void *)title);
10015 } 10016 }
10016 10017
10017 /* 10018 /*
10018 * Sets the data of a row in the container. 10019 * Sets the data of a row in the container.
10019 * Parameters: 10020 * Parameters:
10192 * Cursors the item with the text speficied, and scrolls to that item. 10193 * Cursors the item with the text speficied, and scrolls to that item.
10193 * Parameters: 10194 * Parameters:
10194 * handle: Handle to the window (widget) to be queried. 10195 * handle: Handle to the window (widget) to be queried.
10195 * text: Text usually returned by dw_container_query(). 10196 * text: Text usually returned by dw_container_query().
10196 */ 10197 */
10197 void API dw_container_cursor(HWND handle, char *text) 10198 void API dw_container_cursor(HWND handle, const char *text)
10198 { 10199 {
10199 int index = ListView_GetNextItem(handle, -1, LVNI_ALL); 10200 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
10200 10201
10201 while ( index != -1 ) 10202 while ( index != -1 )
10202 { 10203 {
10270 * Deletes the item with the text speficied. 10271 * Deletes the item with the text speficied.
10271 * Parameters: 10272 * Parameters:
10272 * handle: Handle to the window (widget). 10273 * handle: Handle to the window (widget).
10273 * text: Text usually returned by dw_container_query(). 10274 * text: Text usually returned by dw_container_query().
10274 */ 10275 */
10275 void API dw_container_delete_row(HWND handle, char *text) 10276 void API dw_container_delete_row(HWND handle, const char *text)
10276 { 10277 {
10277 int index = ListView_GetNextItem(handle, -1, LVNI_ALL); 10278 int index = ListView_GetNextItem(handle, -1, LVNI_ALL);
10278 10279
10279 while(index != -1) 10280 while(index != -1)
10280 { 10281 {
10422 * Parameters: 10423 * Parameters:
10423 * handle: Window handle that will handle taskbar icon messages. 10424 * handle: Window handle that will handle taskbar icon messages.
10424 * icon: Icon handle to display in the taskbar. 10425 * icon: Icon handle to display in the taskbar.
10425 * bubbletext: Text to show when the mouse is above the icon. 10426 * bubbletext: Text to show when the mouse is above the icon.
10426 */ 10427 */
10427 void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) 10428 void API dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext)
10428 { 10429 {
10429 NOTIFYICONDATA tnid; 10430 NOTIFYICONDATA tnid;
10430 10431
10431 tnid.cbSize = sizeof(NOTIFYICONDATA); 10432 tnid.cbSize = sizeof(NOTIFYICONDATA);
10432 tnid.hWnd = handle; 10433 tnid.hWnd = handle;
10433 tnid.uID = (UINT)(uintptr_t)icon; 10434 tnid.uID = (UINT)(uintptr_t)icon;
10434 tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; 10435 tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
10435 tnid.uCallbackMessage = WM_USER+2; 10436 tnid.uCallbackMessage = WM_USER+2;
10436 tnid.hIcon = (HICON)icon; 10437 tnid.hIcon = (HICON)icon;
10437 if(bubbletext) 10438 if(bubbletext)
10438 _tcsncpy(tnid.szTip, UTF8toWide(bubbletext), sizeof(tnid.szTip)); 10439 _tcsncpy(tnid.szTip, UTF8toWide(bubbletext), sizeof(tnid.szTip) / sizeof(TCHAR));
10439 else 10440 else
10440 tnid.szTip[0] = 0; 10441 tnid.szTip[0] = 0;
10441 10442
10442 Shell_NotifyIcon(NIM_ADD, &tnid); 10443 Shell_NotifyIcon(NIM_ADD, &tnid);
10443 } 10444 }
10949 * pixmap: Handle to the pixmap. (choose only one of these) 10950 * pixmap: Handle to the pixmap. (choose only one of these)
10950 * x: X coordinate. 10951 * x: X coordinate.
10951 * y: Y coordinate. 10952 * y: Y coordinate.
10952 * text: Text to be displayed. 10953 * text: Text to be displayed.
10953 */ 10954 */
10954 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text) 10955 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, const char *text)
10955 { 10956 {
10956 HDC hdc; 10957 HDC hdc;
10957 int mustdelete = 0; 10958 int mustdelete = 0;
10958 HFONT hFont = 0, oldFont = 0; 10959 HFONT hFont = 0, oldFont = 0;
10959 ColorInfo *cinfo = NULL; 10960 ColorInfo *cinfo = NULL;
11009 * pixmap: Handle to the pixmap. (choose only one of these) 11010 * pixmap: Handle to the pixmap. (choose only one of these)
11010 * text: Text to be queried. 11011 * text: Text to be queried.
11011 * width: Pointer to a variable to be filled in with the width. 11012 * width: Pointer to a variable to be filled in with the width.
11012 * height Pointer to a variable to be filled in with the height. 11013 * height Pointer to a variable to be filled in with the height.
11013 */ 11014 */
11014 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) 11015 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height)
11015 { 11016 {
11016 HDC hdc; 11017 HDC hdc;
11017 int mustdelete = 0; 11018 int mustdelete = 0;
11018 HFONT hFont = NULL, oldFont; 11019 HFONT hFont = NULL, oldFont;
11019 SIZE sz; 11020 SIZE sz;
11166 * DW pick the appropriate file extension. 11167 * DW pick the appropriate file extension.
11167 * (BMP on OS/2 or Windows, XPM on Unix) 11168 * (BMP on OS/2 or Windows, XPM on Unix)
11168 * Returns: 11169 * Returns:
11169 * A handle to a pixmap or NULL on failure. 11170 * A handle to a pixmap or NULL on failure.
11170 */ 11171 */
11171 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) 11172 HPIXMAP API dw_pixmap_new_from_file(HWND handle, const char *filename)
11172 { 11173 {
11173 HPIXMAP pixmap; 11174 HPIXMAP pixmap;
11174 BITMAP bm; 11175 BITMAP bm;
11175 HDC hdc; 11176 HDC hdc;
11176 #ifndef GDIPLUS 11177 #ifndef GDIPLUS
11231 * (BMP on OS/2 or Windows, XPM on Unix) 11232 * (BMP on OS/2 or Windows, XPM on Unix)
11232 * le: length of data 11233 * le: length of data
11233 * Returns: 11234 * Returns:
11234 * A handle to a pixmap or NULL on failure. 11235 * A handle to a pixmap or NULL on failure.
11235 */ 11236 */
11236 HPIXMAP API dw_pixmap_new_from_data(HWND handle, char *data, int len) 11237 HPIXMAP API dw_pixmap_new_from_data(HWND handle, const char *data, int len)
11237 { 11238 {
11238 HPIXMAP pixmap; 11239 HPIXMAP pixmap;
11239 BITMAP bm; 11240 BITMAP bm;
11240 HDC hdc; 11241 HDC hdc;
11241 char *file; 11242 char *file;
11352 * passed to the application via a callback. 11353 * passed to the application via a callback.
11353 * fontname: Name and size of the font in the form "size.fontname" 11354 * fontname: Name and size of the font in the form "size.fontname"
11354 * Returns: 11355 * Returns:
11355 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. 11356 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
11356 */ 11357 */
11357 int API dw_pixmap_set_font(HPIXMAP pixmap, char *fontname) 11358 int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname)
11358 { 11359 {
11359 if(pixmap) 11360 if(pixmap)
11360 { 11361 {
11361 HFONT hfont = _acquire_font2(pixmap->hdc, fontname); 11362 HFONT hfont = _acquire_font2(pixmap->hdc, fontname);
11362 11363
11543 * handle: Module handle returned by dw_module_load() 11544 * handle: Module handle returned by dw_module_load()
11544 * name: Name of the symbol you want the address of. 11545 * name: Name of the symbol you want the address of.
11545 * func: A pointer to a function pointer, to obtain 11546 * func: A pointer to a function pointer, to obtain
11546 * the address. 11547 * the address.
11547 */ 11548 */
11548 int API dw_module_symbol(HMOD handle, char *name, void**func) 11549 int API dw_module_symbol(HMOD handle, const char *name, void**func)
11549 { 11550 {
11550 if(!func || !name) 11551 if(!func || !name)
11551 return DW_ERROR_UNKNOWN; 11552 return DW_ERROR_UNKNOWN;
11552 11553
11553 if(0 == strlen(name)) 11554 if(0 == strlen(name))
11699 * Parameters: 11700 * Parameters:
11700 * eve: Pointer to an event handle to receive handle. 11701 * eve: Pointer to an event handle to receive handle.
11701 * name: Name given to semaphore which can be opened 11702 * name: Name given to semaphore which can be opened
11702 * by other processes. 11703 * by other processes.
11703 */ 11704 */
11704 HEV API dw_named_event_new(char *name) 11705 HEV API dw_named_event_new(const char *name)
11705 { 11706 {
11706 SECURITY_ATTRIBUTES sa; 11707 SECURITY_ATTRIBUTES sa;
11707 11708
11708 sa.nLength = sizeof( SECURITY_ATTRIBUTES); 11709 sa.nLength = sizeof( SECURITY_ATTRIBUTES);
11709 sa.lpSecurityDescriptor = &_dwsd; 11710 sa.lpSecurityDescriptor = &_dwsd;
11715 /* Destroy this semaphore. 11716 /* Destroy this semaphore.
11716 * Parameters: 11717 * Parameters:
11717 * eve: Handle to the semaphore obtained by 11718 * eve: Handle to the semaphore obtained by
11718 * a create call. 11719 * a create call.
11719 */ 11720 */
11720 HEV API dw_named_event_get(char *name) 11721 HEV API dw_named_event_get(const char *name)
11721 { 11722 {
11722 return OpenEvent(EVENT_ALL_ACCESS, FALSE, UTF8toWide(name)); 11723 return OpenEvent(EVENT_ALL_ACCESS, FALSE, UTF8toWide(name));
11723 } 11724 }
11724 11725
11725 /* Resets the event semaphore so threads who call wait 11726 /* Resets the event semaphore so threads who call wait
11789 * handle: A pointer to receive a SHM identifier. 11790 * handle: A pointer to receive a SHM identifier.
11790 * dest: A pointer to a pointer to receive the memory address. 11791 * dest: A pointer to a pointer to receive the memory address.
11791 * size: Size in bytes of the shared memory region to allocate. 11792 * size: Size in bytes of the shared memory region to allocate.
11792 * name: A string pointer to a unique memory name. 11793 * name: A string pointer to a unique memory name.
11793 */ 11794 */
11794 HSHM API dw_named_memory_new(void **dest, int size, char *name) 11795 HSHM API dw_named_memory_new(void **dest, int size, const char *name)
11795 { 11796 {
11796 SECURITY_ATTRIBUTES sa; 11797 SECURITY_ATTRIBUTES sa;
11797 HSHM handle; 11798 HSHM handle;
11798 11799
11799 sa.nLength = sizeof(SECURITY_ATTRIBUTES); 11800 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
11821 * Parameters: 11822 * Parameters:
11822 * dest: A pointer to a pointer to receive the memory address. 11823 * dest: A pointer to a pointer to receive the memory address.
11823 * size: Size in bytes of the shared memory region to requested. 11824 * size: Size in bytes of the shared memory region to requested.
11824 * name: A string pointer to a unique memory name. 11825 * name: A string pointer to a unique memory name.
11825 */ 11826 */
11826 HSHM API dw_named_memory_get(void **dest, int size, char *name) 11827 HSHM API dw_named_memory_get(void **dest, int size, const char *name)
11827 { 11828 {
11828 HSHM handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, UTF8toWide(name)); 11829 HSHM handle = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, UTF8toWide(name));
11829 11830
11830 if(!handle) 11831 if(!handle)
11831 return 0; 11832 return 0;
12247 /* 12248 /*
12248 * Sets the contents of the default clipboard to the supplied text. 12249 * Sets the contents of the default clipboard to the supplied text.
12249 * Parameters: 12250 * Parameters:
12250 * Text. 12251 * Text.
12251 */ 12252 */
12252 void API dw_clipboard_set_text( char *str, int len ) 12253 void API dw_clipboard_set_text(const char *str, int len)
12253 { 12254 {
12254 HGLOBAL ptr1; 12255 HGLOBAL ptr1;
12255 LPTSTR ptr2; 12256 LPTSTR ptr2;
12256 TCHAR *buf; 12257 TCHAR *buf;
12257 #ifdef UNICODE 12258 #ifdef UNICODE
12371 * Returns: 12372 * Returns:
12372 * NULL on error. A malloced buffer containing 12373 * NULL on error. A malloced buffer containing
12373 * the file path on success. 12374 * the file path on success.
12374 * 12375 *
12375 */ 12376 */
12376 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags) 12377 char * API dw_file_browse(const char *title, const char *defpath, char *ext, int flags)
12377 { 12378 {
12378 OPENFILENAME of = {0}; 12379 OPENFILENAME of = {0};
12379 TCHAR filenamebuf[BROWSEBUFSIZE+1] = {0}, *fbuf = filenamebuf; 12380 TCHAR filenamebuf[BROWSEBUFSIZE+1] = {0}, *fbuf = filenamebuf;
12380 TCHAR filterbuf[BROWSEBUFSIZE+1] = {0}; 12381 TCHAR filterbuf[BROWSEBUFSIZE+1] = {0};
12381 TCHAR *exten = UTF8toWide(ext); 12382 TCHAR *exten = UTF8toWide(ext);
12492 * type: Either DW_EXEC_CON or DW_EXEC_GUI. 12493 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
12493 * params: An array of pointers to string arguements. 12494 * params: An array of pointers to string arguements.
12494 * Returns: 12495 * Returns:
12495 * -1 on error. 12496 * -1 on error.
12496 */ 12497 */
12497 int API dw_exec(char *program, int type, char **params) 12498 int API dw_exec(const char *program, int type, char **params)
12498 { 12499 {
12499 char **newparams; 12500 char **newparams;
12500 int retcode, count = 0, z; 12501 int retcode, count = 0, z;
12501 12502
12502 while(params[count]) 12503 while(params[count])
12741 12742
12742 /* Functions for managing the user data lists that are associated with 12743 /* Functions for managing the user data lists that are associated with
12743 * a given window handle. Used in dw_window_set_data() and 12744 * a given window handle. Used in dw_window_set_data() and
12744 * dw_window_get_data(). 12745 * dw_window_get_data().
12745 */ 12746 */
12746 UserData *_find_userdata(UserData **root, char *varname) 12747 UserData *_find_userdata(UserData **root, const char *varname)
12747 { 12748 {
12748 UserData *tmp = *root; 12749 UserData *tmp = *root;
12749 12750
12750 while(tmp) 12751 while(tmp)
12751 { 12752 {
12754 tmp = tmp->next; 12755 tmp = tmp->next;
12755 } 12756 }
12756 return NULL; 12757 return NULL;
12757 } 12758 }
12758 12759
12759 int _new_userdata(UserData **root, char *varname, void *data) 12760 int _new_userdata(UserData **root, const char *varname, void *data)
12760 { 12761 {
12761 UserData *new = _find_userdata(root, varname); 12762 UserData *new = _find_userdata(root, varname);
12762 12763
12763 if(new) 12764 if(new)
12764 { 12765 {
12792 } 12793 }
12793 } 12794 }
12794 return FALSE; 12795 return FALSE;
12795 } 12796 }
12796 12797
12797 int _remove_userdata(UserData **root, char *varname, int all) 12798 int _remove_userdata(UserData **root, const char *varname, int all)
12798 { 12799 {
12799 UserData *prev = NULL, *tmp = *root; 12800 UserData *prev = NULL, *tmp = *root;
12800 12801
12801 while(tmp) 12802 while(tmp)
12802 { 12803 {
12836 * Parameters: 12837 * Parameters:
12837 * window: Window handle of signal to be called back. 12838 * window: Window handle of signal to be called back.
12838 * dataname: A string pointer identifying which signal to be hooked. 12839 * dataname: A string pointer identifying which signal to be hooked.
12839 * data: User data to be passed to the handler function. 12840 * data: User data to be passed to the handler function.
12840 */ 12841 */
12841 void API dw_window_set_data(HWND window, char *dataname, void *data) 12842 void API dw_window_set_data(HWND window, const char *dataname, void *data)
12842 { 12843 {
12843 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA); 12844 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
12844 12845
12845 if(!cinfo) 12846 if(!cinfo)
12846 { 12847 {
12871 * Parameters: 12872 * Parameters:
12872 * window: Window handle of signal to be called back. 12873 * window: Window handle of signal to be called back.
12873 * dataname: A string pointer identifying which signal to be hooked. 12874 * dataname: A string pointer identifying which signal to be hooked.
12874 * data: User data to be passed to the handler function. 12875 * data: User data to be passed to the handler function.
12875 */ 12876 */
12876 void * API dw_window_get_data(HWND window, char *dataname) 12877 void * API dw_window_get_data(HWND window, const char *dataname)
12877 { 12878 {
12878 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA); 12879 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
12879 12880
12880 if(cinfo && cinfo->root && dataname) 12881 if(cinfo && cinfo->root && dataname)
12881 { 12882 {
12959 * window: Window handle of signal to be called back. 12960 * window: Window handle of signal to be called back.
12960 * signame: A string pointer identifying which signal to be hooked. 12961 * signame: A string pointer identifying which signal to be hooked.
12961 * sigfunc: The pointer to the function to be used as the callback. 12962 * sigfunc: The pointer to the function to be used as the callback.
12962 * data: User data to be passed to the handler function. 12963 * data: User data to be passed to the handler function.
12963 */ 12964 */
12964 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) 12965 void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data)
12965 { 12966 {
12966 dw_signal_connect_data(window, signame, sigfunc, NULL, data); 12967 dw_signal_connect_data(window, signame, sigfunc, NULL, data);
12967 } 12968 }
12968 12969
12969 /* 12970 /*
12973 * signame: A string pointer identifying which signal to be hooked. 12974 * signame: A string pointer identifying which signal to be hooked.
12974 * sigfunc: The pointer to the function to be used as the callback. 12975 * sigfunc: The pointer to the function to be used as the callback.
12975 * discfunc: The pointer to the function called when this handler is removed. 12976 * discfunc: The pointer to the function called when this handler is removed.
12976 * data: User data to be passed to the handler function. 12977 * data: User data to be passed to the handler function.
12977 */ 12978 */
12978 void API dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data) 12979 void API dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data)
12979 { 12980 {
12980 ULONG message = 0, id = 0; 12981 ULONG message = 0, id = 0;
12981 12982
12982 if (window && signame && sigfunc) 12983 if (window && signame && sigfunc)
12983 { 12984 {
13012 /* 13013 /*
13013 * Removes callbacks for a given window with given name. 13014 * Removes callbacks for a given window with given name.
13014 * Parameters: 13015 * Parameters:
13015 * window: Window handle of callback to be removed. 13016 * window: Window handle of callback to be removed.
13016 */ 13017 */
13017 void API dw_signal_disconnect_by_name(HWND window, char *signame) 13018 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
13018 { 13019 {
13019 SignalHandler *prev = NULL, *tmp = Root; 13020 SignalHandler *prev = NULL, *tmp = Root;
13020 ULONG message; 13021 ULONG message;
13021 13022
13022 if(!window || !signame || (message = _findsigmessage(signame)) == 0) 13023 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
13143 * utf8string: UTF-8 encoded source string. 13144 * utf8string: UTF-8 encoded source string.
13144 * Returns: 13145 * Returns:
13145 * Wide string that needs to be freed with dw_free() 13146 * Wide string that needs to be freed with dw_free()
13146 * or NULL on failure. 13147 * or NULL on failure.
13147 */ 13148 */
13148 wchar_t * API dw_utf8_to_wchar(char *utf8string) 13149 wchar_t * API dw_utf8_to_wchar(const char *utf8string)
13149 { 13150 {
13150 #ifdef UNICODE 13151 #ifdef UNICODE
13151 return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR))); 13152 return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)));
13152 #else 13153 #else
13153 return NULL; 13154 return NULL;
13160 * wstring: Wide source string. 13161 * wstring: Wide source string.
13161 * Returns: 13162 * Returns:
13162 * UTF-8 encoded string that needs to be freed with dw_free() 13163 * UTF-8 encoded string that needs to be freed with dw_free()
13163 * or NULL on failure. 13164 * or NULL on failure.
13164 */ 13165 */
13165 char * API dw_wchar_to_utf8(wchar_t *wstring) 13166 char * API dw_wchar_to_utf8(const wchar_t *wstring)
13166 { 13167 {
13167 #ifdef UNICODE 13168 #ifdef UNICODE
13168 return _myWideToUTF8(wstring, malloc(WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL))); 13169 return _myWideToUTF8(wstring, malloc(WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL)));
13169 #else 13170 #else
13170 return NULL; 13171 return NULL;