comparison dwtest.c @ 2406:716f38f69073

Move HTML code into html_add() function in dwtest to allow for easier testing with a non-functional notebook control. Also switch to using a dbsoft.org URL for testing since netlabs.org does not support HTTPS.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 28 Mar 2021 18:26:09 +0000
parents f181963f23d5
children 0286ac44d347
comparison
equal deleted inserted replaced
2405:38c17a19e00d 2406:716f38f69073
1980 free(text); 1980 free(text);
1981 } 1981 }
1982 return FALSE; 1982 return FALSE;
1983 } 1983 }
1984 1984
1985 void html_add(void)
1986 {
1987 rawhtml = dw_html_new(1001);
1988 if(rawhtml)
1989 {
1990 HWND htmlstatus;
1991 HWND hbox = dw_box_new(DW_HORZ, 0);
1992 HWND item;
1993 HWND javascript = dw_combobox_new("", 0);
1994
1995 dw_listbox_append(javascript, "window.scrollTo(0,500);");
1996 dw_listbox_append(javascript, "window.document.title;");
1997 dw_listbox_append(javascript, "window.navigator.userAgent;");
1998
1999 dw_box_pack_start( notebookbox7, rawhtml, 0, 100, TRUE, FALSE, 0);
2000 dw_html_raw(rawhtml, "<html><body><center><h1>dwtest</h1></center></body></html>");
2001 html = dw_html_new(1002);
2002
2003 dw_box_pack_start(notebookbox7, hbox, 0, 0, TRUE, FALSE, 0);
2004
2005 /* Add navigation buttons */
2006 item = dw_button_new("Back", 0);
2007 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2008 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_back_clicked), DW_POINTER(html));
2009
2010 item = dw_button_new("Forward", 0);
2011 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2012 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_forward_clicked), DW_POINTER(html));
2013
2014 /* Put in some extra space */
2015 dw_box_pack_start(hbox, 0, 5, 1, FALSE, FALSE, 0);
2016
2017 item = dw_button_new("Reload", 0);
2018 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2019 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_reload_clicked), DW_POINTER(html));
2020
2021 /* Put in some extra space */
2022 dw_box_pack_start(hbox, 0, 5, 1, FALSE, FALSE, 0);
2023 dw_box_pack_start(hbox, javascript, -1, -1, TRUE, FALSE, 0);
2024
2025 item = dw_button_new("Run", 0);
2026 dw_window_set_data(item, "javascript", DW_POINTER(javascript));
2027 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2028 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_run_clicked), DW_POINTER(html));
2029 dw_window_click_default(javascript, item);
2030
2031 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0);
2032 dw_html_url(html, "https://dbsoft.org/dw_help.php");
2033 htmlstatus = dw_status_text_new("HTML status loading...", 0);
2034 dw_box_pack_start( notebookbox7, htmlstatus, 100, -1, TRUE, FALSE, 1);
2035 dw_signal_connect(html, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(web_html_changed), DW_POINTER(htmlstatus));
2036 dw_signal_connect(html, DW_SIGNAL_HTML_RESULT, DW_SIGNAL_FUNC(web_html_result), DW_POINTER(javascript));
2037 }
2038 else
2039 {
2040 html = dw_text_new("HTML widget not available.", 0);
2041 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0);
2042 }
2043 }
2044
1985 /* Pretty list of features corresponding to the DWFEATURE enum in dw.h */ 2045 /* Pretty list of features corresponding to the DWFEATURE enum in dw.h */
1986 char *DWFeatureList[] = { 2046 char *DWFeatureList[] = {
1987 "Supports the HTML Widget", 2047 "Supports the HTML Widget",
1988 "Supports the DW_SIGNAL_HTML_RESULT callback", 2048 "Supports the DW_SIGNAL_HTML_RESULT callback",
1989 "Supports custom window border sizes", 2049 "Supports custom window border sizes",
2098 2158
2099 notebookbox7 = dw_box_new( DW_VERT, 6 ); 2159 notebookbox7 = dw_box_new( DW_VERT, 6 );
2100 notebookpage7 = dw_notebook_page_new( notebook, 1, FALSE ); 2160 notebookpage7 = dw_notebook_page_new( notebook, 1, FALSE );
2101 dw_notebook_pack( notebook, notebookpage7, notebookbox7 ); 2161 dw_notebook_pack( notebook, notebookpage7, notebookbox7 );
2102 dw_notebook_page_set_text( notebook, notebookpage7, "html"); 2162 dw_notebook_page_set_text( notebook, notebookpage7, "html");
2103 2163 html_add();
2104 rawhtml = dw_html_new(1001);
2105 if(rawhtml)
2106 {
2107 HWND htmlstatus;
2108 HWND hbox = dw_box_new(DW_HORZ, 0);
2109 HWND item;
2110 HWND javascript = dw_combobox_new("", 0);
2111
2112 dw_listbox_append(javascript, "window.scrollTo(0,500);");
2113 dw_listbox_append(javascript, "window.document.title;");
2114 dw_listbox_append(javascript, "window.navigator.userAgent;");
2115
2116 dw_box_pack_start( notebookbox7, rawhtml, 0, 100, TRUE, FALSE, 0);
2117 dw_html_raw(rawhtml, "<html><body><center><h1>dwtest</h1></center></body></html>");
2118 html = dw_html_new(1002);
2119
2120 dw_box_pack_start(notebookbox7, hbox, 0, 0, TRUE, FALSE, 0);
2121
2122 /* Add navigation buttons */
2123 item = dw_button_new("Back", 0);
2124 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2125 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_back_clicked), DW_POINTER(html));
2126
2127 item = dw_button_new("Forward", 0);
2128 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2129 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_forward_clicked), DW_POINTER(html));
2130
2131 /* Put in some extra space */
2132 dw_box_pack_start(hbox, 0, 5, 1, FALSE, FALSE, 0);
2133
2134 item = dw_button_new("Reload", 0);
2135 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2136 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_reload_clicked), DW_POINTER(html));
2137
2138 /* Put in some extra space */
2139 dw_box_pack_start(hbox, 0, 5, 1, FALSE, FALSE, 0);
2140 dw_box_pack_start(hbox, javascript, -1, -1, TRUE, FALSE, 0);
2141
2142 item = dw_button_new("Run", 0);
2143 dw_window_set_data(item, "javascript", DW_POINTER(javascript));
2144 dw_box_pack_start(hbox, item, -1, -1, FALSE, FALSE, 0);
2145 dw_signal_connect(item, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(web_run_clicked), DW_POINTER(html));
2146 dw_window_click_default(javascript, item);
2147
2148 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0);
2149 dw_html_url(html, "http://dwindows.netlabs.org");
2150 htmlstatus = dw_status_text_new("HTML status loading...", 0);
2151 dw_box_pack_start( notebookbox7, htmlstatus, 100, -1, TRUE, FALSE, 1);
2152 dw_signal_connect(html, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(web_html_changed), DW_POINTER(htmlstatus));
2153 dw_signal_connect(html, DW_SIGNAL_HTML_RESULT, DW_SIGNAL_FUNC(web_html_result), DW_POINTER(javascript));
2154 }
2155 else
2156 {
2157 html = dw_text_new("HTML widget not available.", 0);
2158 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0);
2159 }
2160 2164
2161 notebookbox8 = dw_box_new( DW_VERT, 7 ); 2165 notebookbox8 = dw_box_new( DW_VERT, 7 );
2162 notebookpage8 = dw_notebook_page_new( notebook, 1, FALSE ); 2166 notebookpage8 = dw_notebook_page_new( notebook, 1, FALSE );
2163 dw_notebook_pack( notebook, notebookpage8, notebookbox8 ); 2167 dw_notebook_pack( notebook, notebookpage8, notebookbox8 );
2164 dw_notebook_page_set_text( notebook, notebookpage8, "scrollbox"); 2168 dw_notebook_page_set_text( notebook, notebookpage8, "scrollbox");