Mercurial > dwindows
comparison win/dw.c @ 2038:133f29e9f488
Win: Hopefully finally const changes for Windows. OS/2 to go.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 17 Nov 2019 05:35:00 +0000 |
parents | ea303d356419 |
children | 82e5c998df2e |
comparison
equal
deleted
inserted
replaced
2037:a00e73284c97 | 2038:133f29e9f488 |
---|---|
5940 * end: If TRUE memu is positioned at the end of the menu. | 5940 * end: If TRUE memu is positioned at the end of the menu. |
5941 * check: If TRUE menu is "check"able. | 5941 * check: If TRUE menu is "check"able. |
5942 * flags: Extended attributes to set on the menu. | 5942 * flags: Extended attributes to set on the menu. |
5943 * submenu: Handle to an existing menu to be a submenu or NULL. | 5943 * submenu: Handle to an existing menu to be a submenu or NULL. |
5944 */ | 5944 */ |
5945 HWND API dw_menu_append_item(HMENUI menux, char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) | 5945 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG id, ULONG flags, int end, int check, HMENUI submenu) |
5946 { | 5946 { |
5947 MENUITEMINFO mii; | 5947 MENUITEMINFO mii; |
5948 HMENU mymenu = (HMENU)menux; | 5948 HMENU mymenu = (HMENU)menux; |
5949 char buffer[31] = {0}; | 5949 char buffer[31] = {0}; |
5950 int is_checked, is_disabled; | 5950 int is_checked, is_disabled; |
5951 char *menutitle = title; | 5951 char *menutitle = (char *)title; |
5952 | 5952 |
5953 /* | 5953 /* |
5954 * Check if this is a menubar; if so get the menu object | 5954 * Check if this is a menubar; if so get the menu object |
5955 * for the menubar | 5955 * for the menubar |
5956 */ | 5956 */ |
6441 * Create a new Entryfield window (widget) to be packed. | 6441 * Create a new Entryfield window (widget) to be packed. |
6442 * Parameters: | 6442 * Parameters: |
6443 * text: The default text to be in the entryfield widget. | 6443 * text: The default text to be in the entryfield widget. |
6444 * id: An ID to be used with dw_window_from_id() or 0L. | 6444 * id: An ID to be used with dw_window_from_id() or 0L. |
6445 */ | 6445 */ |
6446 HWND API dw_entryfield_new(char *text, ULONG id) | 6446 HWND API dw_entryfield_new(const char *text, ULONG id) |
6447 { | 6447 { |
6448 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, | 6448 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE, |
6449 EDITCLASSNAME, | 6449 EDITCLASSNAME, |
6450 UTF8toWide(text), | 6450 UTF8toWide(text), |
6451 ES_WANTRETURN | WS_CHILD | | 6451 ES_WANTRETURN | WS_CHILD | |
6512 * Create a new Combobox window (widget) to be packed. | 6512 * Create a new Combobox window (widget) to be packed. |
6513 * Parameters: | 6513 * Parameters: |
6514 * text: The default text to be in the combpbox widget. | 6514 * text: The default text to be in the combpbox widget. |
6515 * id: An ID to be used with dw_window_from_id() or 0L. | 6515 * id: An ID to be used with dw_window_from_id() or 0L. |
6516 */ | 6516 */ |
6517 HWND API dw_combobox_new(char *text, ULONG id) | 6517 HWND API dw_combobox_new(const char *text, ULONG id) |
6518 { | 6518 { |
6519 HWND tmp = CreateWindow(COMBOBOXCLASSNAME, | 6519 HWND tmp = CreateWindow(COMBOBOXCLASSNAME, |
6520 UTF8toWide(text), | 6520 UTF8toWide(text), |
6521 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | | 6521 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL | |
6522 WS_CLIPCHILDREN | CBS_AUTOHSCROLL | WS_VISIBLE, | 6522 WS_CLIPCHILDREN | CBS_AUTOHSCROLL | WS_VISIBLE, |
6554 * Create a new button window (widget) to be packed. | 6554 * Create a new button window (widget) to be packed. |
6555 * Parameters: | 6555 * Parameters: |
6556 * text: The text to be display by the static text widget. | 6556 * text: The text to be display by the static text widget. |
6557 * id: An ID to be used with dw_window_from_id() or 0L. | 6557 * id: An ID to be used with dw_window_from_id() or 0L. |
6558 */ | 6558 */ |
6559 HWND API dw_button_new(char *text, ULONG id) | 6559 HWND API dw_button_new(const char *text, ULONG id) |
6560 { | 6560 { |
6561 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); | 6561 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); |
6562 | 6562 |
6563 HWND tmp = CreateWindow(BUTTONCLASSNAME, | 6563 HWND tmp = CreateWindow(BUTTONCLASSNAME, |
6564 UTF8toWide(text), | 6564 UTF8toWide(text), |
6934 * Create a new radiobutton window (widget) to be packed. | 6934 * Create a new radiobutton window (widget) to be packed. |
6935 * Parameters: | 6935 * Parameters: |
6936 * text: The text to be display by the static text widget. | 6936 * text: The text to be display by the static text widget. |
6937 * id: An ID to be used with dw_window_from_id() or 0L. | 6937 * id: An ID to be used with dw_window_from_id() or 0L. |
6938 */ | 6938 */ |
6939 HWND API dw_radiobutton_new(char *text, ULONG id) | 6939 HWND API dw_radiobutton_new(const char *text, ULONG id) |
6940 { | 6940 { |
6941 ColorInfo *cinfo; | 6941 ColorInfo *cinfo; |
6942 HWND tmp = CreateWindow(BUTTONCLASSNAME, | 6942 HWND tmp = CreateWindow(BUTTONCLASSNAME, |
6943 UTF8toWide(text), | 6943 UTF8toWide(text), |
6944 WS_CHILD | BS_AUTORADIOBUTTON | | 6944 WS_CHILD | BS_AUTORADIOBUTTON | |
7040 * Create a new checkbox window (widget) to be packed. | 7040 * Create a new checkbox window (widget) to be packed. |
7041 * Parameters: | 7041 * Parameters: |
7042 * text: The text to be display by the static text widget. | 7042 * text: The text to be display by the static text widget. |
7043 * id: An ID to be used with dw_window_from_id() or 0L. | 7043 * id: An ID to be used with dw_window_from_id() or 0L. |
7044 */ | 7044 */ |
7045 HWND API dw_checkbox_new(char *text, ULONG id) | 7045 HWND API dw_checkbox_new(const char *text, ULONG id) |
7046 { | 7046 { |
7047 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); | 7047 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); |
7048 HWND tmp = CreateWindow(BUTTONCLASSNAME, | 7048 HWND tmp = CreateWindow(BUTTONCLASSNAME, |
7049 UTF8toWide(text), | 7049 UTF8toWide(text), |
7050 WS_CHILD | BS_AUTOCHECKBOX | | 7050 WS_CHILD | BS_AUTOCHECKBOX | |
8462 * Parameters: | 8462 * Parameters: |
8463 * handle: Handle to the listbox to be appended to. | 8463 * handle: Handle to the listbox to be appended to. |
8464 * text: Text to append into listbox. | 8464 * text: Text to append into listbox. |
8465 * pos: 0 based position to insert text | 8465 * pos: 0 based position to insert text |
8466 */ | 8466 */ |
8467 void API dw_listbox_insert(HWND handle, char *text, int pos) | 8467 void API dw_listbox_insert(HWND handle, const char *text, int pos) |
8468 { | 8468 { |
8469 TCHAR tmpbuf[100] = {0}; | 8469 TCHAR tmpbuf[100] = {0}; |
8470 | 8470 |
8471 GetClassName(handle, tmpbuf, 99); | 8471 GetClassName(handle, tmpbuf, 99); |
8472 | 8472 |
8727 * Parameters: | 8727 * Parameters: |
8728 * handle: Handle to the MLE to be queried. | 8728 * handle: Handle to the MLE to be queried. |
8729 * buffer: Text buffer to be imported. | 8729 * buffer: Text buffer to be imported. |
8730 * startpoint: Point to start entering text. | 8730 * startpoint: Point to start entering text. |
8731 */ | 8731 */ |
8732 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint) | 8732 unsigned int API dw_mle_import(HWND handle, const char *buffer, int startpoint) |
8733 { | 8733 { |
8734 int textlen, len = GetWindowTextLength(handle); | 8734 int textlen, len = GetWindowTextLength(handle); |
8735 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer); | 8735 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer); |
8736 | 8736 |
8737 if(startpoint < 0) | 8737 if(startpoint < 0) |
8917 * handle: Handle to the MLE to be cleared. | 8917 * handle: Handle to the MLE to be cleared. |
8918 * text: Text to search for. | 8918 * text: Text to search for. |
8919 * point: Start point of search. | 8919 * point: Start point of search. |
8920 * flags: Search specific flags. | 8920 * flags: Search specific flags. |
8921 */ | 8921 */ |
8922 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags) | 8922 int API dw_mle_search(HWND handle, const char *text, int point, unsigned long flags) |
8923 { | 8923 { |
8924 int len = GetWindowTextLength(handle); | 8924 int len = GetWindowTextLength(handle); |
8925 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2); | 8925 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2); |
8926 TCHAR *searchtext = UTF8toWide(text); | 8926 TCHAR *searchtext = UTF8toWide(text); |
8927 int z, textlen, retval = 0; | 8927 int z, textlen, retval = 0; |
11528 * Parameters: | 11528 * Parameters: |
11529 * name: Base name of the shared library. | 11529 * name: Base name of the shared library. |
11530 * handle: Pointer to a module handle, | 11530 * handle: Pointer to a module handle, |
11531 * will be filled in with the handle. | 11531 * will be filled in with the handle. |
11532 */ | 11532 */ |
11533 int API dw_module_load(char *name, HMOD *handle) | 11533 int API dw_module_load(const char *name, HMOD *handle) |
11534 { | 11534 { |
11535 if(!handle) | 11535 if(!handle) |
11536 return DW_ERROR_UNKNOWN; | 11536 return DW_ERROR_UNKNOWN; |
11537 | 11537 |
11538 *handle = LoadLibrary(UTF8toWide(name)); | 11538 *handle = LoadLibrary(UTF8toWide(name)); |
12536 /* | 12536 /* |
12537 * Loads a web browser pointed at the given URL. | 12537 * Loads a web browser pointed at the given URL. |
12538 * Parameters: | 12538 * Parameters: |
12539 * url: Uniform resource locator. | 12539 * url: Uniform resource locator. |
12540 */ | 12540 */ |
12541 int API dw_browse(char *url) | 12541 int API dw_browse(const char *url) |
12542 { | 12542 { |
12543 char *browseurl = url; | 12543 char *browseurl = strdup(url); |
12544 int retcode; | 12544 int retcode; |
12545 | 12545 |
12546 if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0) | 12546 if(strlen(browseurl) > 7 && strncmp(browseurl, "file://", 7) == 0) |
12547 { | 12547 { |
12548 int len, z; | 12548 int len, z; |
12549 | 12549 |
12550 browseurl = &url[7]; | 12550 browseurl = &browseurl[7]; |
12551 len = (int)strlen(browseurl); | 12551 len = (int)strlen(browseurl); |
12552 | 12552 |
12553 for(z=0;z<len;z++) | 12553 for(z=0;z<len;z++) |
12554 { | 12554 { |
12555 if(browseurl[z] == '|') | 12555 if(browseurl[z] == '|') |
12558 browseurl[z] = '\\'; | 12558 browseurl[z] = '\\'; |
12559 } | 12559 } |
12560 } | 12560 } |
12561 | 12561 |
12562 retcode = DW_POINTER_TO_INT(ShellExecute(NULL, TEXT("open"), UTF8toWide(browseurl), NULL, NULL, SW_SHOWNORMAL)); | 12562 retcode = DW_POINTER_TO_INT(ShellExecute(NULL, TEXT("open"), UTF8toWide(browseurl), NULL, NULL, SW_SHOWNORMAL)); |
12563 free(browseurl); | |
12563 if(retcode<33 && retcode != 2) | 12564 if(retcode<33 && retcode != 2) |
12564 return DW_ERROR_UNKNOWN; | 12565 return DW_ERROR_UNKNOWN; |
12565 return DW_ERROR_NONE; | 12566 return DW_ERROR_NONE; |
12566 } | 12567 } |
12567 | 12568 |
12583 * drawfunc: The pointer to the function to be used as the callback. | 12584 * drawfunc: The pointer to the function to be used as the callback. |
12584 * drawdata: User data to be passed to the handler function. | 12585 * drawdata: User data to be passed to the handler function. |
12585 * Returns: | 12586 * Returns: |
12586 * A handle to the print object or NULL on failure. | 12587 * A handle to the print object or NULL on failure. |
12587 */ | 12588 */ |
12588 HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata) | 12589 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata) |
12589 { | 12590 { |
12590 DWPrint *print; | 12591 DWPrint *print; |
12591 | 12592 |
12592 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint)))) | 12593 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint)))) |
12593 return NULL; | 12594 return NULL; |