comparison gtk4/dw.c @ 2305:047ad6a5cc1d

GTK4: Add more functions to the thread safety system... might need to do some more... will evaluate with some testing.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 10 Feb 2021 04:21:37 +0000
parents ae6f678cb1a9
children 558959a64772
comparison
equal deleted inserted replaced
2304:ae6f678cb1a9 2305:047ad6a5cc1d
129 _args[6] = (void *)&param5; \ 129 _args[6] = (void *)&param5; \
130 _args[7] = (void *)&param6; \ 130 _args[7] = (void *)&param6; \
131 _args[8] = (void *)&param7; \ 131 _args[8] = (void *)&param7; \
132 _args[9] = (void *)&param8; \ 132 _args[9] = (void *)&param8; \
133 _args[10] = (void *)&param9; 133 _args[10] = (void *)&param9;
134 #define DW_FUNCTION_ADD_PARAM10(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10) \
135 void **_args = alloca(sizeof(void *)*12); \
136 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
137 _args[1] = (void *)NULL; \
138 _args[2] = (void *)&param1; \
139 _args[3] = (void *)&param2; \
140 _args[4] = (void *)&param3; \
141 _args[5] = (void *)&param4; \
142 _args[6] = (void *)&param5; \
143 _args[7] = (void *)&param6; \
144 _args[8] = (void *)&param7; \
145 _args[9] = (void *)&param8; \
146 _args[10] = (void *)&param9; \
147 _args[11] = (void *)&param10;
148 #define DW_FUNCTION_ADD_PARAM11(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11) \
149 void **_args = alloca(sizeof(void *)*13); \
150 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
151 _args[1] = (void *)NULL; \
152 _args[2] = (void *)&param1; \
153 _args[3] = (void *)&param2; \
154 _args[4] = (void *)&param3; \
155 _args[5] = (void *)&param4; \
156 _args[6] = (void *)&param5; \
157 _args[7] = (void *)&param6; \
158 _args[8] = (void *)&param7; \
159 _args[9] = (void *)&param8; \
160 _args[10] = (void *)&param9; \
161 _args[11] = (void *)&param10; \
162 _args[12] = (void *)&param11;
163 #define DW_FUNCTION_ADD_PARAM12(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12) \
164 void **_args = alloca(sizeof(void *)*14); \
165 _args[0] = (void *)pthread_getspecific(_dw_event_key); \
166 _args[1] = (void *)NULL; \
167 _args[2] = (void *)&param1; \
168 _args[3] = (void *)&param2; \
169 _args[4] = (void *)&param3; \
170 _args[5] = (void *)&param4; \
171 _args[6] = (void *)&param5; \
172 _args[7] = (void *)&param6; \
173 _args[8] = (void *)&param7; \
174 _args[9] = (void *)&param8; \
175 _args[10] = (void *)&param9; \
176 _args[11] = (void *)&param10; \
177 _args[12] = (void *)&param11; \
178 _args[13] = (void *)&param12;
134 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1) \ 179 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1) \
135 vartype1 param1 = *((vartype1 *)_args[2]); 180 vartype1 param1 = *((vartype1 *)_args[2]);
136 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2) \ 181 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2) \
137 vartype1 param1 = *((vartype1 *)_args[2]); \ 182 vartype1 param1 = *((vartype1 *)_args[2]); \
138 vartype2 param2 = *((vartype2 *)_args[3]); 183 vartype2 param2 = *((vartype2 *)_args[3]);
183 vartype5 param5 = *((vartype5 *)_args[6]); \ 228 vartype5 param5 = *((vartype5 *)_args[6]); \
184 vartype6 param6 = *((vartype6 *)_args[7]); \ 229 vartype6 param6 = *((vartype6 *)_args[7]); \
185 vartype7 param7 = *((vartype7 *)_args[8]); \ 230 vartype7 param7 = *((vartype7 *)_args[8]); \
186 vartype8 param8 = *((vartype8 *)_args[9]); \ 231 vartype8 param8 = *((vartype8 *)_args[9]); \
187 vartype9 param9 = *((vartype9 *)_args[10]); 232 vartype9 param9 = *((vartype9 *)_args[10]);
233 #define DW_FUNCTION_RESTORE_PARAM10(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10) \
234 vartype1 param1 = *((vartype1 *)_args[2]); \
235 vartype2 param2 = *((vartype2 *)_args[3]); \
236 vartype3 param3 = *((vartype3 *)_args[4]); \
237 vartype4 param4 = *((vartype4 *)_args[5]); \
238 vartype5 param5 = *((vartype5 *)_args[6]); \
239 vartype6 param6 = *((vartype6 *)_args[7]); \
240 vartype7 param7 = *((vartype7 *)_args[8]); \
241 vartype8 param8 = *((vartype8 *)_args[9]); \
242 vartype9 param9 = *((vartype9 *)_args[10]); \
243 vartype10 param10 = *((vartype10 *)_args[11]);
244 #define DW_FUNCTION_RESTORE_PARAM11(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11) \
245 vartype1 param1 = *((vartype1 *)_args[2]); \
246 vartype2 param2 = *((vartype2 *)_args[3]); \
247 vartype3 param3 = *((vartype3 *)_args[4]); \
248 vartype4 param4 = *((vartype4 *)_args[5]); \
249 vartype5 param5 = *((vartype5 *)_args[6]); \
250 vartype6 param6 = *((vartype6 *)_args[7]); \
251 vartype7 param7 = *((vartype7 *)_args[8]); \
252 vartype8 param8 = *((vartype8 *)_args[9]); \
253 vartype9 param9 = *((vartype9 *)_args[10]); \
254 vartype10 param10 = *((vartype10 *)_args[11]); \
255 vartype11 param11 = *((vartype11 *)_args[12]);
256 #define DW_FUNCTION_RESTORE_PARAM12(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11, param12, vartype12) \
257 vartype1 param1 = *((vartype1 *)_args[2]); \
258 vartype2 param2 = *((vartype2 *)_args[3]); \
259 vartype3 param3 = *((vartype3 *)_args[4]); \
260 vartype4 param4 = *((vartype4 *)_args[5]); \
261 vartype5 param5 = *((vartype5 *)_args[6]); \
262 vartype6 param6 = *((vartype6 *)_args[7]); \
263 vartype7 param7 = *((vartype7 *)_args[8]); \
264 vartype8 param8 = *((vartype8 *)_args[9]); \
265 vartype9 param9 = *((vartype9 *)_args[10]); \
266 vartype10 param10 = *((vartype10 *)_args[11]); \
267 vartype11 param11 = *((vartype11 *)_args[12]); \
268 vartype12 param12 = *((vartype12 *)_args[13]);
188 #define DW_FUNCTION_END } 269 #define DW_FUNCTION_END }
189 #define DW_FUNCTION_NO_RETURN(func) dw_event_reset((HEV)_args[0]); \ 270 #define DW_FUNCTION_NO_RETURN(func) dw_event_reset((HEV)_args[0]); \
190 if(_dw_thread == (pthread_t)-1 || pthread_self() == _dw_thread) \ 271 if(_dw_thread == (pthread_t)-1 || pthread_self() == _dw_thread) \
191 _##func(_args); \ 272 _##func(_args); \
192 else { \ 273 else { \
222 #define DW_FUNCTION_ADD_PARAM5(param1, param2, param3, param4, param5) 303 #define DW_FUNCTION_ADD_PARAM5(param1, param2, param3, param4, param5)
223 #define DW_FUNCTION_ADD_PARAM6(param1, param2, param3, param4, param5, param6) 304 #define DW_FUNCTION_ADD_PARAM6(param1, param2, param3, param4, param5, param6)
224 #define DW_FUNCTION_ADD_PARAM7(param1, param2, param3, param4, param5, param6, param7) 305 #define DW_FUNCTION_ADD_PARAM7(param1, param2, param3, param4, param5, param6, param7)
225 #define DW_FUNCTION_ADD_PARAM8(param1, param2, param3, param4, param5, param6, param7, param8) 306 #define DW_FUNCTION_ADD_PARAM8(param1, param2, param3, param4, param5, param6, param7, param8)
226 #define DW_FUNCTION_ADD_PARAM9(param1, param2, param3, param4, param5, param6, param7, param8, param9) 307 #define DW_FUNCTION_ADD_PARAM9(param1, param2, param3, param4, param5, param6, param7, param8, param9)
308 #define DW_FUNCTION_ADD_PARAM10(param1, param2, param3, param4, param5, param6, param7, param8, param9. param10)
309 #define DW_FUNCTION_ADD_PARAM11(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11)
310 #define DW_FUNCTION_ADD_PARAM12(param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12)
227 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1) 311 #define DW_FUNCTION_RESTORE_PARAM1(param1, vartype1)
228 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2) 312 #define DW_FUNCTION_RESTORE_PARAM2(param1, vartype1, param2, vartype2)
229 #define DW_FUNCTION_RESTORE_PARAM3(param1, vartype1, param2, vartype2, param3, vartype3) 313 #define DW_FUNCTION_RESTORE_PARAM3(param1, vartype1, param2, vartype2, param3, vartype3)
230 #define DW_FUNCTION_RESTORE_PARAM4(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4) 314 #define DW_FUNCTION_RESTORE_PARAM4(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4)
231 #define DW_FUNCTION_RESTORE_PARAM5(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5) 315 #define DW_FUNCTION_RESTORE_PARAM5(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5)
232 #define DW_FUNCTION_RESTORE_PARAM6(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6) 316 #define DW_FUNCTION_RESTORE_PARAM6(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6)
233 #define DW_FUNCTION_RESTORE_PARAM7(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7) 317 #define DW_FUNCTION_RESTORE_PARAM7(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7)
234 #define DW_FUNCTION_RESTORE_PARAM8(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8) 318 #define DW_FUNCTION_RESTORE_PARAM8(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8)
235 #define DW_FUNCTION_RESTORE_PARAM9(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9) 319 #define DW_FUNCTION_RESTORE_PARAM9(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9)
320 #define DW_FUNCTION_RESTORE_PARAM10(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10)
321 #define DW_FUNCTION_RESTORE_PARAM11(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11)
322 #define DW_FUNCTION_RESTORE_PARAM12(param1, vartype1, param2, vartype2, param3, vartype3, param4, vartype4, param5, vartype5, param6, vartype6, param7, vartype7, param8, vartype8, param9, vartype9, param10, vartype10, param11, vartype11, param12, vartype12)
236 #define DW_FUNCTION_END 323 #define DW_FUNCTION_END
237 #define DW_FUNCTION_NO_RETURN(func) 324 #define DW_FUNCTION_NO_RETURN(func)
238 #define DW_FUNCTION_RETURN(func, rettype) 325 #define DW_FUNCTION_RETURN(func, rettype)
239 #define DW_FUNCTION_RETURN_THIS(retvar) return retvar; 326 #define DW_FUNCTION_RETURN_THIS(retvar) return retvar;
240 #define DW_FUNCTION_RETURN_NOTHING 327 #define DW_FUNCTION_RETURN_NOTHING
1089 } 1176 }
1090 } 1177 }
1091 return retval; 1178 return retval;
1092 } 1179 }
1093 1180
1094 static int _round_value(gfloat val) 1181 static int _dw_round_value(gfloat val)
1095 { 1182 {
1096 int newval = (int)val; 1183 int newval = (int)val;
1097 1184
1098 if(val >= 0.5 + (gfloat)newval) 1185 if(val >= 0.5 + (gfloat)newval)
1099 newval++; 1186 newval++;
1112 1199
1113 slider = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_slider"); 1200 slider = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_slider");
1114 spinbutton = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_spinbutton"); 1201 spinbutton = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_spinbutton");
1115 scrollbar = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_scrollbar"); 1202 scrollbar = (GtkWidget *)g_object_get_data(G_OBJECT(adjustment), "_dw_scrollbar");
1116 1203
1117 max = _round_value(gtk_adjustment_get_upper(adjustment)); 1204 max = _dw_round_value(gtk_adjustment_get_upper(adjustment));
1118 val = _round_value(gtk_adjustment_get_value(adjustment)); 1205 val = _dw_round_value(gtk_adjustment_get_value(adjustment));
1119 1206
1120 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event")) 1207 if(g_object_get_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event"))
1121 return FALSE; 1208 return FALSE;
1122 1209
1123 if(slider || spinbutton || scrollbar) 1210 if(slider || spinbutton || scrollbar)
1564 /* 1651 /*
1565 * Minimizes or Iconifies a top-level window. 1652 * Minimizes or Iconifies a top-level window.
1566 * Parameters: 1653 * Parameters:
1567 * handle: The window handle to minimize. 1654 * handle: The window handle to minimize.
1568 */ 1655 */
1569 int dw_window_minimize(HWND handle) 1656 DW_FUNCTION_DEFINITION(dw_window_minimize, int, HWND handle)
1570 { 1657 DW_FUNCTION_ADD_PARAM1(handle)
1658 DW_FUNCTION_RETURN(dw_window_minimize, int)
1659 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
1660 {
1661 int retval = DW_ERROR_NONE;
1662
1571 if(handle && GTK_IS_WINDOW(handle)) 1663 if(handle && GTK_IS_WINDOW(handle))
1572 gtk_window_minimize(GTK_WINDOW(handle)); 1664 gtk_window_minimize(GTK_WINDOW(handle));
1573 return DW_ERROR_NONE; 1665 DW_FUNCTION_RETURN_THIS(retval);
1574 } 1666 }
1575 1667
1576 /* 1668 /*
1577 * Makes the window topmost. 1669 * Makes the window topmost.
1578 * Parameters: 1670 * Parameters:
1598 /* 1690 /*
1599 * Makes the window visible. 1691 * Makes the window visible.
1600 * Parameters: 1692 * Parameters:
1601 * handle: The window handle to make visible. 1693 * handle: The window handle to make visible.
1602 */ 1694 */
1603 int dw_window_show(HWND handle) 1695 DW_FUNCTION_DEFINITION(dw_window_show, int, HWND handle)
1604 { 1696 DW_FUNCTION_ADD_PARAM1(handle)
1605 if (!handle) 1697 DW_FUNCTION_RETURN(dw_window_show, int)
1606 return 0; 1698 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
1607 1699 {
1608 if(GTK_IS_WIDGET(handle)) 1700 int retval = DW_ERROR_NONE;
1609 gtk_widget_show(handle); 1701
1610 if(GTK_IS_WINDOW(handle)) 1702 if(handle)
1611 { 1703 {
1612 GtkWidget *defaultitem; 1704 if(GTK_IS_WIDGET(handle))
1613 1705 gtk_widget_show(handle);
1614 gtk_window_unminimize(GTK_WINDOW(handle)); 1706 if(GTK_IS_WINDOW(handle))
1615 defaultitem = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_defaultitem"); 1707 {
1616 if (defaultitem) 1708 GtkWidget *defaultitem;
1617 gtk_widget_grab_focus(defaultitem); 1709
1618 } 1710 gtk_window_unminimize(GTK_WINDOW(handle));
1619 return 0; 1711 defaultitem = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_defaultitem");
1712 if (defaultitem)
1713 gtk_widget_grab_focus(defaultitem);
1714 }
1715 }
1716 DW_FUNCTION_RETURN_THIS(retval);
1620 } 1717 }
1621 1718
1622 /* 1719 /*
1623 * Makes the window invisible. 1720 * Makes the window invisible.
1624 * Parameters: 1721 * Parameters:
1625 * handle: The window handle to make visible. 1722 * handle: The window handle to make visible.
1626 */ 1723 */
1627 int dw_window_hide(HWND handle) 1724 DW_FUNCTION_DEFINITION(dw_window_hide, int, HWND handle)
1628 { 1725 DW_FUNCTION_ADD_PARAM1(handle)
1629 if(!handle) 1726 DW_FUNCTION_RETURN(dw_window_hide, int)
1630 return 0; 1727 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
1631 1728 {
1632 gtk_widget_hide(handle); 1729 int retval = DW_ERROR_NONE;
1633 return 0; 1730
1731 if(handle && GTK_IS_WIDGET(handle))
1732 gtk_widget_hide(handle);
1733 DW_FUNCTION_RETURN_THIS(retval);
1634 } 1734 }
1635 1735
1636 /* 1736 /*
1637 * Destroys a window and all of it's children. 1737 * Destroys a window and all of it's children.
1638 * Parameters: 1738 * Parameters:
1639 * handle: The window handle to destroy. 1739 * handle: The window handle to destroy.
1640 */ 1740 */
1641 int dw_window_destroy(HWND handle) 1741 DW_FUNCTION_DEFINITION(dw_window_destroy, int, HWND handle)
1642 { 1742 DW_FUNCTION_ADD_PARAM1(handle)
1643 if(!handle) 1743 DW_FUNCTION_RETURN(dw_window_destroy, int)
1644 return 0; 1744 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
1645 1745 {
1646 if(GTK_IS_WINDOW(handle)) 1746 int retval = DW_ERROR_NONE;
1647 gtk_window_destroy(GTK_WINDOW(handle)); 1747
1648 else if(GTK_IS_WIDGET(handle)) 1748 if(handle)
1649 { 1749 {
1650 GtkWidget *box, *handle2 = handle; 1750 if(GTK_IS_WINDOW(handle))
1651 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox"); 1751 gtk_window_destroy(GTK_WINDOW(handle));
1652 1752 else if(GTK_IS_WIDGET(handle))
1653 /* Handle the invisible event box if it exists */ 1753 {
1654 if(eventbox && GTK_IS_WIDGET(eventbox)) 1754 GtkWidget *box, *handle2 = handle;
1655 handle2 = eventbox; 1755 GtkWidget *eventbox = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_eventbox");
1656 1756
1657 /* Check if we are removing a widget from a box */ 1757 /* Handle the invisible event box if it exists */
1658 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box)) 1758 if(eventbox && GTK_IS_WIDGET(eventbox))
1659 { 1759 handle2 = eventbox;
1660 /* Get the number of items in the box... */ 1760
1661 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount")); 1761 /* Check if we are removing a widget from a box */
1662 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype")); 1762 if((box = gtk_widget_get_parent(handle2)) && GTK_IS_GRID(box))
1663 int z;
1664
1665 /* Figure out where in the grid this widget is and remove that row/column */
1666 if(boxtype == DW_VERT)
1667 { 1763 {
1668 for(z=0;z<boxcount;z++) 1764 /* Get the number of items in the box... */
1765 int boxcount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxcount"));
1766 int boxtype = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(box), "_dw_boxtype"));
1767 int z;
1768
1769 /* Figure out where in the grid this widget is and remove that row/column */
1770 if(boxtype == DW_VERT)
1669 { 1771 {
1670 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2) 1772 for(z=0;z<boxcount;z++)
1671 { 1773 {
1672 gtk_grid_remove_row(GTK_GRID(box), z); 1774 if(gtk_grid_get_child_at(GTK_GRID(box), 0, z) == handle2)
1673 break; 1775 {
1776 gtk_grid_remove_row(GTK_GRID(box), z);
1777 break;
1778 }
1674 } 1779 }
1675 } 1780 }
1676 } 1781 else
1677 else
1678 {
1679 for(z=0;z<boxcount;z++)
1680 { 1782 {
1681 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2) 1783 for(z=0;z<boxcount;z++)
1682 { 1784 {
1683 gtk_grid_remove_column(GTK_GRID(box), z); 1785 if(gtk_grid_get_child_at(GTK_GRID(box), z, 0) == handle2)
1684 break; 1786 {
1787 gtk_grid_remove_column(GTK_GRID(box), z);
1788 break;
1789 }
1685 } 1790 }
1686 } 1791 }
1792
1793 if(boxcount > 0)
1794 {
1795 /* Decrease the count by 1 */
1796 boxcount--;
1797 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount));
1798 }
1687 } 1799 }
1688 1800 /* Finally destroy the widget, make sure it is still
1689 if(boxcount > 0) 1801 * a valid widget if it got removed from the grid.
1690 { 1802 */
1691 /* Decrease the count by 1 */ 1803 if(GTK_IS_WIDGET(handle2))
1692 boxcount--; 1804 g_object_unref(G_OBJECT(handle2));
1693 g_object_set_data(G_OBJECT(box), "_dw_boxcount", GINT_TO_POINTER(boxcount)); 1805 }
1694 } 1806 }
1695 } 1807 DW_FUNCTION_RETURN_THIS(retval);
1696 /* Finally destroy the widget, make sure it is still
1697 * a valid widget if it got removed from the grid.
1698 */
1699 if(GTK_IS_WIDGET(handle2))
1700 g_object_unref(G_OBJECT(handle2));
1701 }
1702 return 0;
1703 } 1808 }
1704 1809
1705 /* Causes entire window to be invalidated and redrawn. 1810 /* Causes entire window to be invalidated and redrawn.
1706 * Parameters: 1811 * Parameters:
1707 * handle: Toplevel window handle to be redrawn. 1812 * handle: Toplevel window handle to be redrawn.
1714 * Changes a window's parent to newparent. 1819 * Changes a window's parent to newparent.
1715 * Parameters: 1820 * Parameters:
1716 * handle: The window handle to destroy. 1821 * handle: The window handle to destroy.
1717 * newparent: The window's new parent window. 1822 * newparent: The window's new parent window.
1718 */ 1823 */
1719 void dw_window_reparent(HWND handle, HWND newparent) 1824 DW_FUNCTION_DEFINITION(dw_window_reparent, void, HWND handle, HWND newparent)
1720 { 1825 DW_FUNCTION_ADD_PARAM2(handle, newparent)
1721 if(GTK_IS_WIDGET(handle) && GTK_IS_WIDGET(newparent)) 1826 DW_FUNCTION_NO_RETURN(dw_window_reparent)
1827 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, newparent, HWND)
1828 {
1829 if(handle && GTK_IS_WIDGET(handle) && newparent && GTK_IS_WIDGET(newparent))
1722 gtk_widget_set_parent(GTK_WIDGET(handle), GTK_WIDGET(newparent)); 1830 gtk_widget_set_parent(GTK_WIDGET(handle), GTK_WIDGET(newparent));
1831 DW_FUNCTION_RETURN_NOTHING;
1723 } 1832 }
1724 1833
1725 /* 1834 /*
1726 * Sets the default font used on text based widgets. 1835 * Sets the default font used on text based widgets.
1727 * Parameters: 1836 * Parameters:
1833 * Sets the font used by a specified window (widget) handle. 1942 * Sets the font used by a specified window (widget) handle.
1834 * Parameters: 1943 * Parameters:
1835 * handle: The window (widget) handle. 1944 * handle: The window (widget) handle.
1836 * fontname: Name and size of the font in the form "size.fontname" 1945 * fontname: Name and size of the font in the form "size.fontname"
1837 */ 1946 */
1838 int dw_window_set_font(HWND handle, const char *fontname) 1947 DW_FUNCTION_DEFINITION(dw_window_set_font, int, HWND handle, const char *fontname)
1948 DW_FUNCTION_ADD_PARAM2(handle, fontname)
1949 DW_FUNCTION_RETURN(dw_window_set_font, int)
1950 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, fontname, const char *)
1839 { 1951 {
1840 GtkWidget *handle2 = handle; 1952 GtkWidget *handle2 = handle;
1841 char *font = _convert_font(fontname); 1953 char *font = _convert_font(fontname);
1842 gpointer data; 1954 gpointer data;
1955 int retval = DW_ERROR_NONE;
1843 1956
1844 if(GTK_IS_SCROLLED_WINDOW(handle)) 1957 if(GTK_IS_SCROLLED_WINDOW(handle))
1845 { 1958 {
1846 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 1959 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
1847 if(tmp) 1960 if(tmp)
1873 if(data) 1986 if(data)
1874 free(data); 1987 free(data);
1875 1988
1876 _dw_override_font(handle2, font); 1989 _dw_override_font(handle2, font);
1877 1990
1878 return TRUE; 1991 DW_FUNCTION_RETURN_THIS(retval);
1879 } 1992 }
1880 1993
1881 /* Allows the user to choose a font using the system's font chooser dialog. 1994 /* Allows the user to choose a font using the system's font chooser dialog.
1882 * Parameters: 1995 * Parameters:
1883 * currfont: current font 1996 * currfont: current font
1884 * Returns: 1997 * Returns:
1885 * A malloced buffer with the selected font or NULL on error. 1998 * A malloced buffer with the selected font or NULL on error.
1886 */ 1999 */
1887 char * API dw_font_choose(const char *currfont) 2000 DW_FUNCTION_DEFINITION(dw_font_choose, char *, const char *currfont)
2001 DW_FUNCTION_ADD_PARAM1(currfont)
2002 DW_FUNCTION_RETURN(dw_font_choose, char *)
2003 DW_FUNCTION_RESTORE_PARAM1(currfont, const char *)
1888 { 2004 {
1889 GtkFontChooser *fd; 2005 GtkFontChooser *fd;
1890 char *font = currfont ? strdup(currfont) : NULL; 2006 char *font = currfont ? strdup(currfont) : NULL;
1891 char *name = font ? strchr(font, '.') : NULL; 2007 char *name = font ? strchr(font, '.') : NULL;
1892 char *retfont = NULL; 2008 char *retfont = NULL;
1943 g_free(fontname); 2059 g_free(fontname);
1944 } 2060 }
1945 } 2061 }
1946 if(GTK_IS_WINDOW(fd)) 2062 if(GTK_IS_WINDOW(fd))
1947 gtk_window_destroy(GTK_WINDOW(fd)); 2063 gtk_window_destroy(GTK_WINDOW(fd));
1948 return retfont; 2064 DW_FUNCTION_RETURN_THIS(retfont);
1949 } 2065 }
1950 2066
1951 /* 2067 /*
1952 * Gets the font used by a specified window (widget) handle. 2068 * Gets the font used by a specified window (widget) handle.
1953 * Parameters: 2069 * Parameters:
1954 * handle: The window (widget) handle. 2070 * handle: The window (widget) handle.
1955 */ 2071 */
1956 char *dw_window_get_font(HWND handle) 2072 DW_FUNCTION_DEFINITION(dw_window_get_font, char *, HWND handle)
2073 DW_FUNCTION_ADD_PARAM1(handle)
2074 DW_FUNCTION_RETURN(dw_window_get_font, char *)
2075 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
1957 { 2076 {
1958 PangoFontDescription *pfont; 2077 PangoFontDescription *pfont;
1959 PangoContext *pcontext; 2078 PangoContext *pcontext;
1960 GtkWidget *handle2 = handle; 2079 GtkWidget *handle2 = handle;
1961 char *font; 2080 char *font;
2008 } 2127 }
2009 } 2128 }
2010 g_free(font); 2129 g_free(font);
2011 } 2130 }
2012 } 2131 }
2013 return retfont; 2132 DW_FUNCTION_RETURN_THIS(retfont);
2014 } 2133 }
2015 2134
2016 void _free_gdk_colors(HWND handle) 2135 void _dw_free_gdk_colors(HWND handle)
2017 { 2136 {
2018 GdkRGBA *old = (GdkRGBA *)g_object_get_data(G_OBJECT(handle), "_dw_foregdk"); 2137 GdkRGBA *old = (GdkRGBA *)g_object_get_data(G_OBJECT(handle), "_dw_foregdk");
2019 2138
2020 if(old) 2139 if(old)
2021 free(old); 2140 free(old);
2025 if(old) 2144 if(old)
2026 free(old); 2145 free(old);
2027 } 2146 }
2028 2147
2029 /* Free old color pointers and allocate new ones */ 2148 /* Free old color pointers and allocate new ones */
2030 static void _save_gdk_colors(HWND handle, GdkRGBA fore, GdkRGBA back) 2149 static void _dw_save_gdk_colors(HWND handle, GdkRGBA fore, GdkRGBA back)
2031 { 2150 {
2032 GdkRGBA *foregdk = malloc(sizeof(GdkRGBA)); 2151 GdkRGBA *foregdk = malloc(sizeof(GdkRGBA));
2033 GdkRGBA *backgdk = malloc(sizeof(GdkRGBA)); 2152 GdkRGBA *backgdk = malloc(sizeof(GdkRGBA));
2034 2153
2035 _free_gdk_colors(handle); 2154 _dw_free_gdk_colors(handle);
2036 2155
2037 *foregdk = fore; 2156 *foregdk = fore;
2038 *backgdk = back; 2157 *backgdk = back;
2039 2158
2040 g_object_set_data(G_OBJECT(handle), "_dw_foregdk", (gpointer)foregdk); 2159 g_object_set_data(G_OBJECT(handle), "_dw_foregdk", (gpointer)foregdk);
2041 g_object_set_data(G_OBJECT(handle), "_dw_backgdk", (gpointer)backgdk); 2160 g_object_set_data(G_OBJECT(handle), "_dw_backgdk", (gpointer)backgdk);
2042 } 2161 }
2043 2162
2044 static int _set_color(HWND handle, unsigned long fore, unsigned long back) 2163 static int _dw_set_color(HWND handle, unsigned long fore, unsigned long back)
2045 { 2164 {
2046 /* Remember that each color component in X11 use 16 bit no matter 2165 /* Remember that each color component in X11 use 16 bit no matter
2047 * what the destination display supports. (and thus GDK) 2166 * what the destination display supports. (and thus GDK)
2048 */ 2167 */
2049 GdkRGBA forecolor = {0}, backcolor = {0}; 2168 GdkRGBA forecolor = {0}, backcolor = {0};
2070 else if(back != DW_CLR_DEFAULT) 2189 else if(back != DW_CLR_DEFAULT)
2071 backcolor = _colors[back]; 2190 backcolor = _colors[back];
2072 2191
2073 _dw_override_color(handle, "background-color", back != DW_CLR_DEFAULT ? &backcolor : NULL); 2192 _dw_override_color(handle, "background-color", back != DW_CLR_DEFAULT ? &backcolor : NULL);
2074 2193
2075 _save_gdk_colors(handle, forecolor, backcolor); 2194 _dw_save_gdk_colors(handle, forecolor, backcolor);
2076 2195
2077 return TRUE; 2196 return TRUE;
2078 } 2197 }
2079 /* 2198 /*
2080 * Sets the colors used by a specified window (widget) handle. 2199 * Sets the colors used by a specified window (widget) handle.
2081 * Parameters: 2200 * Parameters:
2082 * handle: The window (widget) handle. 2201 * handle: The window (widget) handle.
2083 * fore: Foreground color in RGB format. 2202 * fore: Foreground color in RGB format.
2084 * back: Background color in RGB format. 2203 * back: Background color in RGB format.
2085 */ 2204 */
2086 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back) 2205 DW_FUNCTION_DEFINITION(dw_window_set_color, int, HWND handle, unsigned long fore, unsigned long back)
2206 DW_FUNCTION_ADD_PARAM3(handle, fore, back)
2207 DW_FUNCTION_RETURN(dw_window_set_color, int)
2208 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, fore, unsigned long, back, unsigned long)
2087 { 2209 {
2088 GtkWidget *handle2 = handle; 2210 GtkWidget *handle2 = handle;
2211 int retval = DW_ERROR_NONE;
2089 2212
2090 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle)) 2213 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle))
2091 { 2214 {
2092 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 2215 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
2093 if(tmp) 2216 if(tmp)
2101 handle2 = tmp; 2224 handle2 = tmp;
2102 fore = DW_CLR_DEFAULT; 2225 fore = DW_CLR_DEFAULT;
2103 } 2226 }
2104 } 2227 }
2105 2228
2106 _set_color(handle2, fore, back); 2229 _dw_set_color(handle2, fore, back);
2107 2230
2108 return TRUE; 2231 DW_FUNCTION_RETURN_THIS(retval);
2109 } 2232 }
2110 2233
2111 /* 2234 /*
2112 * Sets the font used by a specified window (widget) handle. 2235 * Sets the font used by a specified window (widget) handle.
2113 * Parameters: 2236 * Parameters:
2134 * Changes the appearance of the mouse pointer. 2257 * Changes the appearance of the mouse pointer.
2135 * Parameters: 2258 * Parameters:
2136 * handle: Handle to widget for which to change. 2259 * handle: Handle to widget for which to change.
2137 * cursortype: ID of the pointer you want. 2260 * cursortype: ID of the pointer you want.
2138 */ 2261 */
2139 void dw_window_set_pointer(HWND handle, int pointertype) 2262 DW_FUNCTION_DEFINITION(dw_window_set_pointer, void, HWND handle, int pointertype)
2263 DW_FUNCTION_ADD_PARAM2(handle, pointertype)
2264 DW_FUNCTION_NO_RETURN(dw_window_set_pointer)
2265 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pointertype, int)
2140 { 2266 {
2141 if(pointertype > 65535) 2267 if(pointertype > 65535)
2142 { 2268 {
2143 GdkPixbuf *pixbuf = _dw_find_pixbuf(GINT_TO_POINTER(pointertype), NULL, NULL); 2269 GdkPixbuf *pixbuf = _dw_find_pixbuf(GINT_TO_POINTER(pointertype), NULL, NULL);
2144 GdkCursor *cursor = gdk_cursor_new_from_texture(gdk_texture_new_for_pixbuf(pixbuf), 0, 0, NULL); 2270 GdkCursor *cursor = gdk_cursor_new_from_texture(gdk_texture_new_for_pixbuf(pixbuf), 0, 0, NULL);
2151 gtk_widget_set_cursor_from_name(GTK_WIDGET(handle), "wait"); 2277 gtk_widget_set_cursor_from_name(GTK_WIDGET(handle), "wait");
2152 else if(pointertype == DW_POINTER_QUESTION) 2278 else if(pointertype == DW_POINTER_QUESTION)
2153 gtk_widget_set_cursor_from_name(GTK_WIDGET(handle), "help"); 2279 gtk_widget_set_cursor_from_name(GTK_WIDGET(handle), "help");
2154 else 2280 else
2155 gtk_widget_set_cursor(GTK_WIDGET(handle), NULL); 2281 gtk_widget_set_cursor(GTK_WIDGET(handle), NULL);
2282 DW_FUNCTION_RETURN_NOTHING;
2156 } 2283 }
2157 2284
2158 /* 2285 /*
2159 * Releases previous mouse capture. 2286 * Releases previous mouse capture.
2160 */ 2287 */
2171 * Parameters: 2298 * Parameters:
2172 * owner: The Owner's window handle or HWND_DESKTOP. 2299 * owner: The Owner's window handle or HWND_DESKTOP.
2173 * title: The Window title. 2300 * title: The Window title.
2174 * flStyle: Style flags, see the PM reference. 2301 * flStyle: Style flags, see the PM reference.
2175 */ 2302 */
2176 HWND dw_window_new(HWND hwndOwner, const char *title, unsigned long flStyle) 2303 DW_FUNCTION_DEFINITION(dw_window_new, HWND, DW_UNUSED(HWND hwndOwner), const char *title, ULONG flStyle)
2304 DW_FUNCTION_ADD_PARAM3(hwndOwner, title, flStyle)
2305 DW_FUNCTION_RETURN(dw_window_new, HWND)
2306 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(hwndOwner), HWND, title, char *, flStyle, ULONG)
2177 { 2307 {
2178 GtkWidget *box = dw_box_new(DW_VERT, 0); 2308 GtkWidget *box = dw_box_new(DW_VERT, 0);
2179 GtkWidget *grid = gtk_grid_new(); 2309 GtkWidget *grid = gtk_grid_new();
2180 GtkWidget *tmp = gtk_window_new(); 2310 GtkWidget *tmp = gtk_window_new();
2181 2311
2204 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1); 2334 gtk_grid_attach(GTK_GRID(grid), box, 0, 1, 1, 1);
2205 gtk_window_set_child(GTK_WINDOW(tmp), grid); 2335 gtk_window_set_child(GTK_WINDOW(tmp), grid);
2206 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box); 2336 g_object_set_data(G_OBJECT(tmp), "_dw_boxhandle", (gpointer)box);
2207 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid); 2337 g_object_set_data(G_OBJECT(tmp), "_dw_grid", (gpointer)grid);
2208 g_object_set_data(G_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle)); 2338 g_object_set_data(G_OBJECT(tmp), "_dw_style", GINT_TO_POINTER(flStyle));
2209 return tmp; 2339 DW_FUNCTION_RETURN_THIS(tmp);
2210 } 2340 }
2211 2341
2212 /* 2342 /*
2213 * Create a new Box to be packed. 2343 * Create a new Box to be packed.
2214 * Parameters: 2344 * Parameters:
2231 * Create a new scrollable Box to be packed. 2361 * Create a new scrollable Box to be packed.
2232 * Parameters: 2362 * Parameters:
2233 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 2363 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
2234 * pad: Number of pixels to pad around the box. 2364 * pad: Number of pixels to pad around the box.
2235 */ 2365 */
2236 HWND dw_scrollbox_new(int type, int pad) 2366 DW_FUNCTION_DEFINITION(dw_scrollbox_new, HWND, int type, int pad)
2367 DW_FUNCTION_ADD_PARAM2(type, pad)
2368 DW_FUNCTION_RETURN(dw_scrollbox_new, HWND)
2369 DW_FUNCTION_RESTORE_PARAM2(type, int, pad, int)
2237 { 2370 {
2238 GtkWidget *tmp, *box; 2371 GtkWidget *tmp, *box;
2239 2372
2240 tmp = gtk_scrolled_window_new(); 2373 tmp = gtk_scrolled_window_new();
2241 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tmp), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); 2374 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tmp), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
2249 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tmp), box); 2382 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tmp), box);
2250 g_object_set_data(G_OBJECT(tmp), "_dw_user", box); 2383 g_object_set_data(G_OBJECT(tmp), "_dw_user", box);
2251 gtk_widget_show(box); 2384 gtk_widget_show(box);
2252 gtk_widget_show(tmp); 2385 gtk_widget_show(tmp);
2253 2386
2254 return tmp; 2387 DW_FUNCTION_RETURN_THIS(tmp);
2255 } 2388 }
2256 2389
2257 /* 2390 /*
2258 * Returns the position of the scrollbar in the scrollbox 2391 * Returns the position of the scrollbar in the scrollbox
2259 * Parameters: 2392 * Parameters:
2260 * handle: Handle to the scrollbox to be queried. 2393 * handle: Handle to the scrollbox to be queried.
2261 * orient: The vertical or horizontal scrollbar. 2394 * orient: The vertical or horizontal scrollbar.
2262 */ 2395 */
2263 int dw_scrollbox_get_pos(HWND handle, int orient) 2396 DW_FUNCTION_DEFINITION(dw_scrollbox_get_pos, int, HWND handle, int orient)
2264 { 2397 DW_FUNCTION_ADD_PARAM2(handle, orient)
2265 int val = -1; 2398 DW_FUNCTION_RETURN(dw_scrollbox_get_pos, int)
2399 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, orient, int)
2400 {
2401 int val = DW_ERROR_UNKNOWN;
2266 GtkAdjustment *adjustment; 2402 GtkAdjustment *adjustment;
2267 2403
2268 if (!handle) 2404 if(handle)
2269 return -1; 2405 {
2270 2406 if(orient == DW_HORZ)
2271 if ( orient == DW_HORZ ) 2407 adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(handle));
2272 adjustment = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW(handle) ); 2408 else
2273 else 2409 adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
2274 adjustment = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(handle) ); 2410 if(adjustment)
2275 if (adjustment) 2411 val = _dw_round_value(gtk_adjustment_get_value(adjustment));
2276 val = _round_value(gtk_adjustment_get_value(adjustment)); 2412 }
2277 return val; 2413 DW_FUNCTION_RETURN_THIS(val);
2278 } 2414 }
2279 2415
2280 /* 2416 /*
2281 * Gets the range for the scrollbar in the scrollbox. 2417 * Gets the range for the scrollbar in the scrollbox.
2282 * Parameters: 2418 * Parameters:
2283 * handle: Handle to the scrollbox to be queried. 2419 * handle: Handle to the scrollbox to be queried.
2284 * orient: The vertical or horizontal scrollbar. 2420 * orient: The vertical or horizontal scrollbar.
2285 */ 2421 */
2286 int API dw_scrollbox_get_range(HWND handle, int orient) 2422 DW_FUNCTION_DEFINITION(dw_scrollbox_get_range, int, HWND handle, int orient)
2287 { 2423 DW_FUNCTION_ADD_PARAM2(handle, orient)
2288 int range = -1; 2424 DW_FUNCTION_RETURN(dw_scrollbox_get_range, int)
2425 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, orient, int)
2426 {
2427 int range = DW_ERROR_UNKNOWN;
2289 GtkAdjustment *adjustment; 2428 GtkAdjustment *adjustment;
2290 2429
2291 if (!handle) 2430 if(handle)
2292 return -1; 2431 {
2293 2432 if(orient == DW_HORZ)
2294 if ( orient == DW_HORZ ) 2433 adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(handle));
2295 adjustment = gtk_scrolled_window_get_hadjustment( GTK_SCROLLED_WINDOW(handle) ); 2434 else
2296 else 2435 adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
2297 adjustment = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(handle) ); 2436 if(adjustment)
2298 if (adjustment) 2437 range = _dw_round_value(gtk_adjustment_get_upper(adjustment));
2299 { 2438 }
2300 range = _round_value(gtk_adjustment_get_upper(adjustment)); 2439 DW_FUNCTION_RETURN_THIS(range);
2301 }
2302 return range;
2303 } 2440 }
2304 2441
2305 /* 2442 /*
2306 * Create a new Group Box to be packed. 2443 * Create a new Group Box to be packed.
2307 * Parameters: 2444 * Parameters:
2308 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal). 2445 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
2309 * pad: Number of pixels to pad around the box. 2446 * pad: Number of pixels to pad around the box.
2310 * title: Text to be displayined in the group outline. 2447 * title: Text to be displayined in the group outline.
2311 */ 2448 */
2312 HWND dw_groupbox_new(int type, int pad, const char *title) 2449 DW_FUNCTION_DEFINITION(dw_groupbox_new, HWND, int type, int pad, const char *title)
2313 { 2450 DW_FUNCTION_ADD_PARAM3(type, pad, title)
2314 GtkWidget *tmp, *frame; 2451 DW_FUNCTION_RETURN(dw_groupbox_new, HWND)
2315 2452 DW_FUNCTION_RESTORE_PARAM3(type, int, pad, int, title, const char *)
2316 frame = gtk_frame_new(NULL); 2453 {
2454 GtkWidget *tmp, *frame = gtk_frame_new(NULL);
2317 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL); 2455 gtk_frame_set_label(GTK_FRAME(frame), title && *title ? title : NULL);
2318 2456
2319 tmp = gtk_grid_new(); 2457 tmp = gtk_grid_new();
2320 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type)); 2458 g_object_set_data(G_OBJECT(tmp), "_dw_boxtype", GINT_TO_POINTER(type));
2321 g_object_set_data(G_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp); 2459 g_object_set_data(G_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp);
2323 gtk_frame_set_child(GTK_FRAME(frame), tmp); 2461 gtk_frame_set_child(GTK_FRAME(frame), tmp);
2324 gtk_widget_show(tmp); 2462 gtk_widget_show(tmp);
2325 gtk_widget_show(frame); 2463 gtk_widget_show(frame);
2326 if(_DWDefaultFont) 2464 if(_DWDefaultFont)
2327 dw_window_set_font(frame, _DWDefaultFont); 2465 dw_window_set_font(frame, _DWDefaultFont);
2328 return frame; 2466 DW_FUNCTION_RETURN_THIS(frame);
2329 } 2467 }
2330 2468
2331 /* 2469 /*
2332 * Create a bitmap object to be packed. 2470 * Create a bitmap object to be packed.
2333 * Parameters: 2471 * Parameters:
2334 * id: An ID to be used with dw_window_from_id() or 0L. 2472 * id: An ID to be used with dw_window_from_id() or 0L.
2335 */ 2473 */
2336 HWND dw_bitmap_new(unsigned long id) 2474 DW_FUNCTION_DEFINITION(dw_bitmap_new, HWND, ULONG cid)
2337 { 2475 DW_FUNCTION_ADD_PARAM1(cid)
2338 GtkWidget *tmp; 2476 DW_FUNCTION_RETURN(dw_bitmap_new, HWND)
2339 2477 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2340 tmp = gtk_image_new(); 2478 {
2479 GtkWidget *tmp = gtk_image_new();
2341 gtk_widget_show(tmp); 2480 gtk_widget_show(tmp);
2342 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 2481 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2343 return tmp; 2482 DW_FUNCTION_RETURN_THIS(tmp);
2344 } 2483 }
2345 2484
2346 /* 2485 /*
2347 * Create a notebook object to be packed. 2486 * Create a notebook object to be packed.
2348 * Parameters: 2487 * Parameters:
2349 * id: An ID to be used for getting the resource from the 2488 * id: An ID to be used for getting the resource from the
2350 * resource file. 2489 * resource file.
2351 */ 2490 */
2352 HWND dw_notebook_new(unsigned long id, int top) 2491 DW_FUNCTION_DEFINITION(dw_notebook_new, HWND, ULONG cid, int top)
2492 DW_FUNCTION_ADD_PARAM2(cid, top)
2493 DW_FUNCTION_RETURN(dw_notebook_new, HWND)
2494 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, top, int)
2353 { 2495 {
2354 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256); 2496 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
2355 2497
2356 tmp = gtk_notebook_new(); 2498 tmp = gtk_notebook_new();
2357 if(top) 2499 if(top)
2358 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP); 2500 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
2359 else 2501 else
2360 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM); 2502 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_BOTTOM);
2361 gtk_notebook_set_scrollable(GTK_NOTEBOOK(tmp), TRUE); 2503 gtk_notebook_set_scrollable(GTK_NOTEBOOK(tmp), TRUE);
2362 gtk_widget_show(tmp); 2504 gtk_widget_show(tmp);
2363 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 2505 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2364 g_object_set_data(G_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray); 2506 g_object_set_data(G_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray);
2365 return tmp; 2507 DW_FUNCTION_RETURN_THIS(tmp);
2366 } 2508 }
2367 2509
2368 static unsigned int _dw_menugroup = 0; 2510 static unsigned int _dw_menugroup = 0;
2369 2511
2370 /* Recurse into a menu setting the action groups on the menuparent widget */ 2512 /* Recurse into a menu setting the action groups on the menuparent widget */
2425 * Parameters: 2567 * Parameters:
2426 * location: Handle of a window frame to be attached to. 2568 * location: Handle of a window frame to be attached to.
2427 * If there is no box already packed into the "location", the menu will not appear 2569 * If there is no box already packed into the "location", the menu will not appear
2428 * so tell the user. 2570 * so tell the user.
2429 */ 2571 */
2430 HMENUI dw_menubar_new(HWND location) 2572 DW_FUNCTION_DEFINITION(dw_menubar_new, HMENUI, HWND location)
2573 DW_FUNCTION_ADD_PARAM1(location)
2574 DW_FUNCTION_RETURN(dw_menubar_new, HMENUI)
2575 DW_FUNCTION_RESTORE_PARAM1(location, HWND)
2431 { 2576 {
2432 HMENUI tmp = 0; 2577 HMENUI tmp = 0;
2433 GtkWidget *box; 2578 GtkWidget *box;
2434 2579
2435 if(GTK_IS_WINDOW(location) && 2580 if(GTK_IS_WINDOW(location) &&
2462 g_object_set_data(G_OBJECT(tmp), "_dw_group", (gpointer)group); 2607 g_object_set_data(G_OBJECT(tmp), "_dw_group", (gpointer)group);
2463 g_object_set_data(G_OBJECT(tmp), "_dw_section", (gpointer)section); 2608 g_object_set_data(G_OBJECT(tmp), "_dw_section", (gpointer)section);
2464 gtk_grid_attach(GTK_GRID(box), tmp, 0, 0, 1, 1); 2609 gtk_grid_attach(GTK_GRID(box), tmp, 0, 0, 1, 1);
2465 _dw_menu_set_group_recursive(tmp, GTK_WIDGET(tmp)); 2610 _dw_menu_set_group_recursive(tmp, GTK_WIDGET(tmp));
2466 } 2611 }
2467 return tmp; 2612 DW_FUNCTION_RETURN_THIS(tmp);
2468 } 2613 }
2469 2614
2470 /* 2615 /*
2471 * Destroys a menu created with dw_menubar_new or dw_menu_new. 2616 * Destroys a menu created with dw_menubar_new or dw_menu_new.
2472 * Parameters: 2617 * Parameters:
2473 * menu: Handle of a menu. 2618 * menu: Handle of a menu.
2474 */ 2619 */
2475 void dw_menu_destroy(HMENUI *menu) 2620 DW_FUNCTION_DEFINITION(dw_menu_destroy, void, HMENUI *menu)
2621 DW_FUNCTION_ADD_PARAM1(menu)
2622 DW_FUNCTION_NO_RETURN(dw_menu_destroy)
2623 DW_FUNCTION_RESTORE_PARAM1(menu, HMENUI *)
2476 { 2624 {
2477 if(menu && *menu) 2625 if(menu && *menu)
2478 { 2626 {
2479 GtkWidget *window = NULL; 2627 GtkWidget *window = NULL;
2480 2628
2493 } 2641 }
2494 else if(G_IS_MENU(*menu)) 2642 else if(G_IS_MENU(*menu))
2495 g_object_unref(G_OBJECT(*menu)); 2643 g_object_unref(G_OBJECT(*menu));
2496 *menu = NULL; 2644 *menu = NULL;
2497 } 2645 }
2646 DW_FUNCTION_RETURN_NOTHING;
2498 } 2647 }
2499 2648
2500 char _dw_removetilde(char *dest, const char *src) 2649 char _dw_removetilde(char *dest, const char *src)
2501 { 2650 {
2502 int z, cur=0; 2651 int z, cur=0;
2527 * flags: Extended attributes to set on the menu. 2676 * flags: Extended attributes to set on the menu.
2528 * end: If TRUE memu is positioned at the end of the menu. 2677 * end: If TRUE memu is positioned at the end of the menu.
2529 * check: If TRUE menu is "check"able. 2678 * check: If TRUE menu is "check"able.
2530 * submenu: Handle to an existing menu to be a submenu or NULL. 2679 * submenu: Handle to an existing menu to be a submenu or NULL.
2531 */ 2680 */
2532 HWND dw_menu_append_item(HMENUI menu, const char *title, unsigned long id, unsigned long flags, int end, int check, HMENUI submenu) 2681 DW_FUNCTION_DEFINITION(dw_menu_append_item, HWND, HMENUI menu, const char *title, unsigned long id, unsigned long flags, int end, DW_UNUSED(int check), HMENUI submenu)
2682 DW_FUNCTION_ADD_PARAM7(menu, title, id, flags, end, check, submenu)
2683 DW_FUNCTION_RETURN(dw_menu_append_item, HWND)
2684 DW_FUNCTION_RESTORE_PARAM7(menu, HMENUI, title, const char *, id, unsigned long, flags, unsigned long, end, int, DW_UNUSED(check), int, submenu, HMENUI)
2533 { 2685 {
2534 GSimpleAction *action = NULL; 2686 GSimpleAction *action = NULL;
2535 GMenuItem *tmphandle = NULL; 2687 HWND tmphandle = NULL;
2536 GMenuModel *menumodel; 2688 GMenuModel *menumodel;
2537 char *temptitle = alloca(strlen(title)+1); 2689 char *temptitle = alloca(strlen(title)+1);
2538 2690
2539 if(!menu) 2691 if(menu)
2540 return 0; 2692 {
2541 2693 /* By default we add to the menu's current section */
2542 /* By default we add to the menu's current section */ 2694 menumodel = g_object_get_data(G_OBJECT(menu), "_dw_section");
2543 menumodel = g_object_get_data(G_OBJECT(menu), "_dw_section"); 2695 _dw_removetilde(temptitle, title);
2544 _dw_removetilde(temptitle, title); 2696
2545 2697 /* To add a separator we create a new section and add it */
2546 /* To add a separator we create a new section and add it */ 2698 if (strlen(temptitle) == 0)
2547 if (strlen(temptitle) == 0) 2699 {
2548 { 2700 GMenu *section = g_menu_new();
2549 GMenu *section = g_menu_new(); 2701
2550 2702 /* If we are creating a new section, add it to the core menu... not the section */
2551 /* If we are creating a new section, add it to the core menu... not the section */ 2703 if(GTK_IS_POPOVER_MENU_BAR(menu))
2552 if(GTK_IS_POPOVER_MENU_BAR(menu)) 2704 menumodel = gtk_popover_menu_bar_get_menu_model(GTK_POPOVER_MENU_BAR(menu));
2553 menumodel = gtk_popover_menu_bar_get_menu_model(GTK_POPOVER_MENU_BAR(menu)); 2705 else
2706 menumodel = G_MENU_MODEL(menu);
2707
2708 tmphandle = (HWND)g_menu_item_new_section(NULL, G_MENU_MODEL(section));
2709 g_object_set_data(G_OBJECT(menu), "_dw_section", (gpointer)section);
2710 }
2554 else 2711 else
2555 menumodel = G_MENU_MODEL(menu); 2712 {
2556 2713 char tempbuf[101] = {0};
2557 tmphandle = g_menu_item_new_section(NULL, G_MENU_MODEL(section)); 2714
2558 g_object_set_data(G_OBJECT(menu), "_dw_section", (gpointer)section); 2715 if(submenu)
2559 }
2560 else
2561 {
2562 char tempbuf[101] = {0};
2563
2564 if(submenu)
2565 {
2566 if(G_IS_MENU(submenu))
2567 { 2716 {
2568 int submenucount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_submenucount")); 2717 if(G_IS_MENU(submenu))
2569 GtkWidget *menuparent = GTK_WIDGET(g_object_get_data(G_OBJECT(menu), "_dw_menuparent")); 2718 {
2570 2719 int submenucount = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_submenucount"));
2571 /* If the menu being added to is a menu bar, that is the menuparent for submenus */ 2720 GtkWidget *menuparent = GTK_WIDGET(g_object_get_data(G_OBJECT(menu), "_dw_menuparent"));
2572 if(GTK_IS_POPOVER_MENU_BAR(menu)) 2721
2573 menuparent = GTK_WIDGET(menu); 2722 /* If the menu being added to is a menu bar, that is the menuparent for submenus */
2574 2723 if(GTK_IS_POPOVER_MENU_BAR(menu))
2575 snprintf(tempbuf, 100, "_dw_submenu%d", submenucount); 2724 menuparent = GTK_WIDGET(menu);
2576 submenucount++; 2725
2577 tmphandle = g_menu_item_new_submenu(temptitle, G_MENU_MODEL(submenu)); 2726 snprintf(tempbuf, 100, "_dw_submenu%d", submenucount);
2578 g_object_set_data(G_OBJECT(menu), tempbuf, (gpointer)submenu); 2727 submenucount++;
2579 g_object_set_data(G_OBJECT(menu), "_dw_submenucount", GINT_TO_POINTER(submenucount)); 2728 tmphandle = (HWND)g_menu_item_new_submenu(temptitle, G_MENU_MODEL(submenu));
2580 2729 g_object_set_data(G_OBJECT(menu), tempbuf, (gpointer)submenu);
2581 /* If we have a menu parent, use it to create the groups if needed */ 2730 g_object_set_data(G_OBJECT(menu), "_dw_submenucount", GINT_TO_POINTER(submenucount));
2582 if(menuparent && !g_object_get_data(G_OBJECT(submenu), "_dw_menuparent")) 2731
2583 _dw_menu_set_group_recursive(menu, menuparent); 2732 /* If we have a menu parent, use it to create the groups if needed */
2733 if(menuparent && !g_object_get_data(G_OBJECT(submenu), "_dw_menuparent"))
2734 _dw_menu_set_group_recursive(menu, menuparent);
2735 }
2584 } 2736 }
2585 } 2737 else
2738 {
2739 char numbuf[25] = {0};
2740 GSimpleActionGroup *group = g_object_get_data(G_OBJECT(menu), "_dw_group");
2741 int menugroup = DW_POINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_menugroup"));
2742 char *actionname;
2743
2744 snprintf(tempbuf, 100, "menu%d.action%lu", menugroup, id);
2745 actionname = strchr(tempbuf, '.');
2746 action = g_simple_action_new(&actionname[1], NULL);
2747 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
2748 tmphandle=(HWND)g_menu_item_new(temptitle, tempbuf);
2749 snprintf(numbuf, 24, "%lu", id);
2750 g_object_set_data(G_OBJECT(menu), numbuf, (gpointer)tmphandle);
2751 g_object_set_data(G_OBJECT(tmphandle), "_dw_action", (gpointer)action);
2752 }
2753 }
2754
2755 if(end)
2756 g_menu_append_item(G_MENU(menumodel), G_MENU_ITEM(tmphandle));
2586 else 2757 else
2587 { 2758 g_menu_prepend_item(G_MENU(menumodel), G_MENU_ITEM(tmphandle));
2588 char numbuf[25] = {0}; 2759
2589 GSimpleActionGroup *group = g_object_get_data(G_OBJECT(menu), "_dw_group"); 2760 g_object_set_data(G_OBJECT(tmphandle), "_dw_id", GINT_TO_POINTER(id));
2590 int menugroup = DW_POINTER_TO_INT(g_object_get_data(G_OBJECT(menu), "_dw_menugroup")); 2761
2591 char *actionname; 2762 if(action)
2592 2763 g_simple_action_set_enabled(action, (flags & DW_MIS_DISABLED) ? FALSE : TRUE);
2593 snprintf(tempbuf, 100, "menu%d.action%lu", menugroup, id); 2764 }
2594 actionname = strchr(tempbuf, '.'); 2765 DW_FUNCTION_RETURN_THIS(tmphandle);
2595 action = g_simple_action_new(&actionname[1], NULL);
2596 g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action));
2597 tmphandle=g_menu_item_new(temptitle, tempbuf);
2598 snprintf(numbuf, 24, "%lu", id);
2599 g_object_set_data(G_OBJECT(menu), numbuf, (gpointer)tmphandle);
2600 g_object_set_data(G_OBJECT(tmphandle), "_dw_action", (gpointer)action);
2601 }
2602 }
2603
2604 if(end)
2605 g_menu_append_item(G_MENU(menumodel), tmphandle);
2606 else
2607 g_menu_prepend_item(G_MENU(menumodel), tmphandle);
2608
2609 g_object_set_data(G_OBJECT(tmphandle), "_dw_id", GINT_TO_POINTER(id));
2610
2611 if(action)
2612 g_simple_action_set_enabled(action, (flags & DW_MIS_DISABLED) ? FALSE : TRUE);
2613 return (HWND)tmphandle;
2614 } 2766 }
2615 2767
2616 GMenuItem *_dw_find_submenu_id(HMENUI start, const char *name) 2768 GMenuItem *_dw_find_submenu_id(HMENUI start, const char *name)
2617 { 2769 {
2618 GMenuItem *tmp; 2770 GMenuItem *tmp;
2768 * menu: The handle the the existing menu. 2920 * menu: The handle the the existing menu.
2769 * parent: Handle to the window initiating the popup. 2921 * parent: Handle to the window initiating the popup.
2770 * x: X coordinate. 2922 * x: X coordinate.
2771 * y: Y coordinate. 2923 * y: Y coordinate.
2772 */ 2924 */
2773 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) 2925 DW_FUNCTION_DEFINITION(dw_menu_popup, void, HMENUI *menu, HWND parent, int x, int y)
2926 DW_FUNCTION_ADD_PARAM4(menu, parent, x, y)
2927 DW_FUNCTION_NO_RETURN(dw_menu_popup)
2928 DW_FUNCTION_RESTORE_PARAM4(menu, HMENUI *, parent, HWND, x, int, y, int)
2774 { 2929 {
2775 if(menu && *menu && G_MENU(*menu)) 2930 if(menu && *menu && G_MENU(*menu))
2776 { 2931 {
2777 GtkWidget *tmp = gtk_popover_menu_new_from_model_full(G_MENU_MODEL(*menu), GTK_POPOVER_MENU_NESTED); 2932 GtkWidget *tmp = gtk_popover_menu_new_from_model_full(G_MENU_MODEL(*menu), GTK_POPOVER_MENU_NESTED);
2778 GdkRectangle rect = { x, y, 1, 1 }; 2933 GdkRectangle rect = { x, y, 1, 1 };
2795 gtk_popover_set_pointing_to(GTK_POPOVER(tmp), &rect); 2950 gtk_popover_set_pointing_to(GTK_POPOVER(tmp), &rect);
2796 g_signal_connect(G_OBJECT(tmp), "closed", G_CALLBACK(_dw_popover_menu_closed), (gpointer)parent); 2951 g_signal_connect(G_OBJECT(tmp), "closed", G_CALLBACK(_dw_popover_menu_closed), (gpointer)parent);
2797 gtk_popover_popup(GTK_POPOVER(tmp)); 2952 gtk_popover_popup(GTK_POPOVER(tmp));
2798 *menu = NULL; 2953 *menu = NULL;
2799 } 2954 }
2955 DW_FUNCTION_RETURN_NOTHING;
2800 } 2956 }
2801 2957
2802 2958
2803 /* 2959 /*
2804 * Returns the current X and Y coordinates of the mouse pointer. 2960 * Returns the current X and Y coordinates of the mouse pointer.
2805 * Parameters: 2961 * Parameters:
2806 * x: Pointer to variable to store X coordinate. 2962 * x: Pointer to variable to store X coordinate.
2807 * y: Pointer to variable to store Y coordinate. 2963 * y: Pointer to variable to store Y coordinate.
2808 */ 2964 */
2809 void dw_pointer_query_pos(long *x, long *y) 2965 DW_FUNCTION_DEFINITION(dw_pointer_query_pos, void, long *x, long *y)
2966 DW_FUNCTION_ADD_PARAM2(x, y)
2967 DW_FUNCTION_NO_RETURN(dw_pointer_query_pos)
2968 DW_FUNCTION_RESTORE_PARAM2(x, long *, y, long *)
2810 { 2969 {
2811 GdkSeat *seat = gdk_display_get_default_seat(gdk_display_get_default()); 2970 GdkSeat *seat = gdk_display_get_default_seat(gdk_display_get_default());
2812 GdkDevice *mouse = gdk_seat_get_pointer(seat); 2971 GdkDevice *mouse = gdk_seat_get_pointer(seat);
2813 double dx, dy; 2972 double dx, dy;
2814 2973
2816 2975
2817 if(x) 2976 if(x)
2818 *x = (long)dx; 2977 *x = (long)dx;
2819 if(y) 2978 if(y)
2820 *y = (long)dy; 2979 *y = (long)dy;
2980 DW_FUNCTION_RETURN_NOTHING;
2821 } 2981 }
2822 2982
2823 /* 2983 /*
2824 * Sets the X and Y coordinates of the mouse pointer. 2984 * Sets the X and Y coordinates of the mouse pointer.
2825 * Parameters: 2985 * Parameters:
2929 * Create a new static text window (widget) to be packed. 3089 * Create a new static text window (widget) to be packed.
2930 * Parameters: 3090 * Parameters:
2931 * text: The text to be display by the static text widget. 3091 * text: The text to be display by the static text widget.
2932 * id: An ID to be used with dw_window_from_id() or 0L. 3092 * id: An ID to be used with dw_window_from_id() or 0L.
2933 */ 3093 */
2934 HWND dw_text_new(const char *text, unsigned long id) 3094 DW_FUNCTION_DEFINITION(dw_text_new, HWND, const char *text, ULONG cid)
2935 { 3095 DW_FUNCTION_ADD_PARAM2(text, cid)
2936 GtkWidget *tmp; 3096 DW_FUNCTION_RETURN(dw_text_new, HWND)
2937 3097 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2938 tmp = gtk_label_new(text); 3098 {
3099 GtkWidget *tmp = gtk_label_new(text);
2939 3100
2940 /* Left and centered */ 3101 /* Left and centered */
2941 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f); 3102 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f);
2942 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f); 3103 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f);
2943 gtk_widget_show(tmp); 3104 gtk_widget_show(tmp);
2944 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3105 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2945 if(_DWDefaultFont) 3106 if(_DWDefaultFont)
2946 dw_window_set_font(tmp, _DWDefaultFont); 3107 dw_window_set_font(tmp, _DWDefaultFont);
2947 return tmp; 3108 DW_FUNCTION_RETURN_THIS(tmp);
2948 } 3109 }
2949 3110
2950 /* 3111 /*
2951 * Create a new status text window (widget) to be packed. 3112 * Create a new status text window (widget) to be packed.
2952 * Parameters: 3113 * Parameters:
2953 * text: The text to be display by the static text widget. 3114 * text: The text to be display by the static text widget.
2954 * id: An ID to be used with dw_window_from_id() or 0L. 3115 * id: An ID to be used with dw_window_from_id() or 0L.
2955 */ 3116 */
2956 HWND dw_status_text_new(const char *text, ULONG id) 3117 DW_FUNCTION_DEFINITION(dw_status_text_new, HWND, const char *text, ULONG cid)
2957 { 3118 DW_FUNCTION_ADD_PARAM2(text, cid)
2958 GtkWidget *tmp, *frame; 3119 DW_FUNCTION_RETURN(dw_status_text_new, HWND)
2959 3120 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
2960 frame = gtk_frame_new(NULL); 3121 {
3122 GtkWidget *tmp, *frame = gtk_frame_new(NULL);
2961 tmp = gtk_label_new(text); 3123 tmp = gtk_label_new(text);
2962 gtk_frame_set_child(GTK_FRAME(frame), tmp); 3124 gtk_frame_set_child(GTK_FRAME(frame), tmp);
2963 gtk_widget_show(tmp); 3125 gtk_widget_show(tmp);
2964 gtk_widget_show(frame); 3126 gtk_widget_show(frame);
2965 3127
2966 /* Left and centered */ 3128 /* Left and centered */
2967 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f); 3129 gtk_label_set_xalign(GTK_LABEL(tmp), 0.0f);
2968 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f); 3130 gtk_label_set_yalign(GTK_LABEL(tmp), 0.5f);
2969 g_object_set_data(G_OBJECT(frame), "_dw_id", GINT_TO_POINTER(id)); 3131 g_object_set_data(G_OBJECT(frame), "_dw_id", GINT_TO_POINTER(cid));
2970 g_object_set_data(G_OBJECT(frame), "_dw_label", (gpointer)tmp); 3132 g_object_set_data(G_OBJECT(frame), "_dw_label", (gpointer)tmp);
2971 if(_DWDefaultFont) 3133 if(_DWDefaultFont)
2972 dw_window_set_font(tmp, _DWDefaultFont); 3134 dw_window_set_font(tmp, _DWDefaultFont);
2973 return frame; 3135 DW_FUNCTION_RETURN_THIS(tmp);
2974 } 3136 }
2975 3137
2976 /* 3138 /*
2977 * Create a new Multiline Editbox window (widget) to be packed. 3139 * Create a new Multiline Editbox window (widget) to be packed.
2978 * Parameters: 3140 * Parameters:
2979 * id: An ID to be used with dw_window_from_id() or 0L. 3141 * id: An ID to be used with dw_window_from_id() or 0L.
2980 */ 3142 */
2981 HWND dw_mle_new(unsigned long id) 3143 DW_FUNCTION_DEFINITION(dw_mle_new, HWND, ULONG cid)
2982 { 3144 DW_FUNCTION_ADD_PARAM1(cid)
2983 GtkWidget *tmp, *tmpbox; 3145 DW_FUNCTION_RETURN(dw_mle_new, HWND)
2984 3146 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
2985 tmpbox = gtk_scrolled_window_new(); 3147 {
3148 GtkWidget *tmp, *tmpbox = gtk_scrolled_window_new();
2986 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tmpbox), 3149 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(tmpbox),
2987 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); 3150 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
2988 tmp = gtk_text_view_new(); 3151 tmp = gtk_text_view_new();
2989 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tmpbox), tmp); 3152 gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(tmpbox), tmp);
2990 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD); 3153 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD);
2991 3154
2992 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3155 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
2993 g_object_set_data(G_OBJECT(tmpbox), "_dw_user", (gpointer)tmp); 3156 g_object_set_data(G_OBJECT(tmpbox), "_dw_user", (gpointer)tmp);
2994 gtk_widget_show(tmp); 3157 gtk_widget_show(tmp);
2995 gtk_widget_show(tmpbox); 3158 gtk_widget_show(tmpbox);
2996 if(_DWDefaultFont) 3159 if(_DWDefaultFont)
2997 dw_window_set_font(tmpbox, _DWDefaultFont); 3160 dw_window_set_font(tmpbox, _DWDefaultFont);
2998 return tmpbox; 3161 DW_FUNCTION_RETURN_THIS(tmpbox);
2999 } 3162 }
3000 3163
3001 /* 3164 /*
3002 * Create a new Entryfield window (widget) to be packed. 3165 * Create a new Entryfield window (widget) to be packed.
3003 * Parameters: 3166 * Parameters:
3004 * text: The default text to be in the entryfield widget. 3167 * text: The default text to be in the entryfield widget.
3005 * id: An ID to be used with dw_window_from_id() or 0L. 3168 * id: An ID to be used with dw_window_from_id() or 0L.
3006 */ 3169 */
3007 HWND dw_entryfield_new(const char *text, unsigned long id) 3170 DW_FUNCTION_DEFINITION(dw_entryfield_new, HWND, const char *text, ULONG cid)
3008 { 3171 DW_FUNCTION_ADD_PARAM2(text, cid)
3009 GtkWidget *tmp; 3172 DW_FUNCTION_RETURN(dw_entryfield_new, HWND)
3173 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3174 {
3010 GtkEntryBuffer *buffer = gtk_entry_buffer_new(text, -1); 3175 GtkEntryBuffer *buffer = gtk_entry_buffer_new(text, -1);
3011 3176 GtkWidget *tmp = gtk_entry_new_with_buffer(buffer);
3012 tmp = gtk_entry_new_with_buffer(buffer);
3013 3177
3014 gtk_widget_show(tmp); 3178 gtk_widget_show(tmp);
3015 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3179 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3016 3180
3017 if(_DWDefaultFont) 3181 if(_DWDefaultFont)
3018 dw_window_set_font(tmp, _DWDefaultFont); 3182 dw_window_set_font(tmp, _DWDefaultFont);
3019 return tmp; 3183 DW_FUNCTION_RETURN_THIS(tmp);
3020 } 3184 }
3021 3185
3022 /* 3186 /*
3023 * Create a new Entryfield (password) window (widget) to be packed. 3187 * Create a new Entryfield (password) window (widget) to be packed.
3024 * Parameters: 3188 * Parameters:
3025 * text: The default text to be in the entryfield widget. 3189 * text: The default text to be in the entryfield widget.
3026 * id: An ID to be used with dw_window_from_id() or 0L. 3190 * id: An ID to be used with dw_window_from_id() or 0L.
3027 */ 3191 */
3028 HWND dw_entryfield_password_new(const char *text, ULONG id) 3192 DW_FUNCTION_DEFINITION(dw_entryfield_password_new, HWND, const char *text, ULONG cid)
3029 { 3193 DW_FUNCTION_ADD_PARAM2(text, cid)
3030 GtkWidget *tmp; 3194 DW_FUNCTION_RETURN(dw_entryfield_password_new, HWND)
3195 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3196 {
3031 GtkEntryBuffer *buffer = gtk_entry_buffer_new(text, -1); 3197 GtkEntryBuffer *buffer = gtk_entry_buffer_new(text, -1);
3032 3198 GtkWidget *tmp = gtk_entry_new_with_buffer(buffer);
3033 tmp = gtk_entry_new_with_buffer(buffer);
3034 3199
3035 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE); 3200 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
3036 3201
3037 gtk_widget_show(tmp); 3202 gtk_widget_show(tmp);
3038 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3203 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3039 3204
3040 if(_DWDefaultFont) 3205 if(_DWDefaultFont)
3041 dw_window_set_font(tmp, _DWDefaultFont); 3206 dw_window_set_font(tmp, _DWDefaultFont);
3042 return tmp; 3207 DW_FUNCTION_RETURN_THIS(tmp);
3043 } 3208 }
3044 3209
3045 /* 3210 /*
3046 * Create a new Combobox window (widget) to be packed. 3211 * Create a new Combobox window (widget) to be packed.
3047 * Parameters: 3212 * Parameters:
3053 DW_FUNCTION_RETURN(dw_combobox_new, HWND) 3218 DW_FUNCTION_RETURN(dw_combobox_new, HWND)
3054 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG) 3219 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3055 { 3220 {
3056 GtkWidget *tmp; 3221 GtkWidget *tmp;
3057 GtkEntryBuffer *buffer; 3222 GtkEntryBuffer *buffer;
3058 GtkListStore *store; 3223 GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);
3059
3060 store = gtk_list_store_new(1, G_TYPE_STRING);
3061 tmp = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store)); 3224 tmp = gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(store));
3062 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(tmp), 0); 3225 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(tmp), 0);
3063 buffer = gtk_entry_get_buffer(GTK_ENTRY(gtk_combo_box_get_child(GTK_COMBO_BOX(tmp)))); 3226 buffer = gtk_entry_get_buffer(GTK_ENTRY(gtk_combo_box_get_child(GTK_COMBO_BOX(tmp))));
3064 gtk_entry_buffer_set_max_length(buffer, 0); 3227 gtk_entry_buffer_set_max_length(buffer, 0);
3065 gtk_entry_buffer_set_text(buffer, text, -1); 3228 gtk_entry_buffer_set_text(buffer, text, -1);
3075 * Create a new button window (widget) to be packed. 3238 * Create a new button window (widget) to be packed.
3076 * Parameters: 3239 * Parameters:
3077 * text: The text to be display by the static text widget. 3240 * text: The text to be display by the static text widget.
3078 * id: An ID to be used with dw_window_from_id() or 0L. 3241 * id: An ID to be used with dw_window_from_id() or 0L.
3079 */ 3242 */
3080 HWND dw_button_new(const char *text, unsigned long id) 3243 DW_FUNCTION_DEFINITION(dw_button_new, HWND, const char *text, ULONG cid)
3081 { 3244 DW_FUNCTION_ADD_PARAM2(text, cid)
3082 GtkWidget *tmp; 3245 DW_FUNCTION_RETURN(dw_button_new, HWND)
3083 3246 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3084 tmp = gtk_button_new_with_label(text); 3247 {
3248 GtkWidget *tmp = gtk_button_new_with_label(text);
3085 gtk_widget_show(tmp); 3249 gtk_widget_show(tmp);
3086 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3250 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3087 if(_DWDefaultFont) 3251 if(_DWDefaultFont)
3088 dw_window_set_font(tmp, _DWDefaultFont); 3252 dw_window_set_font(tmp, _DWDefaultFont);
3089 return tmp; 3253 DW_FUNCTION_RETURN_THIS(tmp);
3090 } 3254 }
3091 3255
3092 /* 3256 /*
3093 * Create a new bitmap button window (widget) to be packed. 3257 * Create a new bitmap button window (widget) to be packed.
3094 * Parameters: 3258 * Parameters:
3095 * text: Bubble help text to be displayed. 3259 * text: Bubble help text to be displayed.
3096 * id: An ID of a bitmap in the resource file. 3260 * id: An ID of a bitmap in the resource file.
3097 */ 3261 */
3098 HWND dw_bitmapbutton_new(const char *text, unsigned long id) 3262 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new, HWND, const char *text, ULONG cid)
3099 { 3263 DW_FUNCTION_ADD_PARAM2(text, cid)
3100 GtkWidget *tmp; 3264 DW_FUNCTION_RETURN(dw_bitmapbutton_new, HWND)
3101 GtkWidget *bitmap; 3265 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3102 3266 {
3103 tmp = gtk_button_new(); 3267 GtkWidget *tmp = gtk_button_new();
3104 bitmap = dw_bitmap_new(id); 3268 GtkWidget *bitmap = dw_bitmap_new(cid);
3105 3269
3106 if(bitmap) 3270 if(bitmap)
3107 { 3271 {
3108 dw_window_set_bitmap(bitmap, id, NULL); 3272 dw_window_set_bitmap(bitmap, cid, NULL);
3109 gtk_button_set_child(GTK_BUTTON(tmp), bitmap); 3273 gtk_button_set_child(GTK_BUTTON(tmp), bitmap);
3110 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap); 3274 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
3111 } 3275 }
3112 gtk_widget_show(tmp); 3276 gtk_widget_show(tmp);
3113 if(text) 3277 if(text)
3114 gtk_widget_set_tooltip_text(tmp, text); 3278 gtk_widget_set_tooltip_text(tmp, text);
3115 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3279 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3116 return tmp; 3280 DW_FUNCTION_RETURN_THIS(tmp);
3117 } 3281 }
3118 3282
3119 /* 3283 /*
3120 * Create a new bitmap button window (widget) to be packed from a file. 3284 * Create a new bitmap button window (widget) to be packed from a file.
3121 * Parameters: 3285 * Parameters:
3124 * id: An ID to be used with dw_window_from_id() or 0L. 3288 * id: An ID to be used with dw_window_from_id() or 0L.
3125 * filename: Name of the file, omit extention to have 3289 * filename: Name of the file, omit extention to have
3126 * DW pick the appropriate file extension. 3290 * DW pick the appropriate file extension.
3127 * (BMP on OS/2 or Windows, XPM on Unix) 3291 * (BMP on OS/2 or Windows, XPM on Unix)
3128 */ 3292 */
3129 HWND dw_bitmapbutton_new_from_file(const char *text, unsigned long id, const char *filename) 3293 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_file, HWND, const char *text, ULONG cid, const char *filename)
3130 { 3294 DW_FUNCTION_ADD_PARAM3(text, cid, filename)
3131 GtkWidget *tmp; 3295 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_file, HWND)
3132 GtkWidget *bitmap; 3296 DW_FUNCTION_RESTORE_PARAM3(text, const char *, cid, ULONG, filename, const char *)
3133 3297 {
3134 /* Create a new button */ 3298 GtkWidget *tmp = gtk_button_new();
3135 tmp = gtk_button_new(); 3299 GtkWidget *bitmap = dw_bitmap_new(cid);
3136 /* Now on to the image stuff */ 3300
3137 bitmap = dw_bitmap_new(id);
3138 if(bitmap) 3301 if(bitmap)
3139 { 3302 {
3140 dw_window_set_bitmap(bitmap, 0, filename); 3303 dw_window_set_bitmap(bitmap, 0, filename);
3141 gtk_button_set_child(GTK_BUTTON(tmp), bitmap); 3304 gtk_button_set_child(GTK_BUTTON(tmp), bitmap);
3142 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap); 3305 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
3143 } 3306 }
3144 gtk_widget_show(tmp); 3307 gtk_widget_show(tmp);
3145 if(text) 3308 if(text)
3146 gtk_widget_set_tooltip_text(tmp, text); 3309 gtk_widget_set_tooltip_text(tmp, text);
3147 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3310 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3148 return tmp; 3311 DW_FUNCTION_RETURN_THIS(tmp);
3149 } 3312 }
3150 3313
3151 /* 3314 /*
3152 * Create a new bitmap button window (widget) to be packed from data. 3315 * Create a new bitmap button window (widget) to be packed from data.
3153 * Parameters: 3316 * Parameters:
3155 * id: An ID to be used with dw_window_from_id() or 0L. 3318 * id: An ID to be used with dw_window_from_id() or 0L.
3156 * data: Raw data of image. 3319 * data: Raw data of image.
3157 * (BMP on OS/2 or Windows, XPM on Unix) 3320 * (BMP on OS/2 or Windows, XPM on Unix)
3158 * len: Length of raw data 3321 * len: Length of raw data
3159 */ 3322 */
3160 HWND dw_bitmapbutton_new_from_data(const char *text, unsigned long id, const char *data, int len) 3323 DW_FUNCTION_DEFINITION(dw_bitmapbutton_new_from_data, HWND, const char *text, ULONG cid, const char *data, int len)
3161 { 3324 DW_FUNCTION_ADD_PARAM4(text, cid, data, len)
3162 GtkWidget *tmp; 3325 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_data, HWND)
3163 GtkWidget *bitmap; 3326 DW_FUNCTION_RESTORE_PARAM4(text, const char *, cid, ULONG, data, const char *, len, int)
3164 3327 {
3165 tmp = gtk_button_new(); 3328 GtkWidget *tmp = gtk_button_new();
3166 bitmap = dw_bitmap_new(id); 3329 GtkWidget *bitmap = dw_bitmap_new(cid);
3167 3330
3168 if(bitmap) 3331 if(bitmap)
3169 { 3332 {
3170 dw_window_set_bitmap_from_data(bitmap, 0, data, len); 3333 dw_window_set_bitmap_from_data(bitmap, 0, data, len);
3171 gtk_button_set_child(GTK_BUTTON(tmp), bitmap); 3334 gtk_button_set_child(GTK_BUTTON(tmp), bitmap);
3172 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap); 3335 g_object_set_data(G_OBJECT(tmp), "_dw_bitmap", bitmap);
3173 } 3336 }
3174 gtk_widget_show(tmp); 3337 gtk_widget_show(tmp);
3175 if(text) 3338 if(text)
3176 gtk_widget_set_tooltip_text(tmp, text); 3339 gtk_widget_set_tooltip_text(tmp, text);
3177 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3340 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3178 return tmp; 3341 DW_FUNCTION_RETURN_THIS(tmp);
3179 } 3342 }
3180 3343
3181 /* 3344 /*
3182 * Create a new spinbutton window (widget) to be packed. 3345 * Create a new spinbutton window (widget) to be packed.
3183 * Parameters: 3346 * Parameters:
3184 * text: The text to be display by the static text widget. 3347 * text: The text to be display by the static text widget.
3185 * id: An ID to be used with dw_window_from_id() or 0L. 3348 * id: An ID to be used with dw_window_from_id() or 0L.
3186 */ 3349 */
3187 HWND dw_spinbutton_new(const char *text, unsigned long id) 3350 DW_FUNCTION_DEFINITION(dw_spinbutton_new, HWND, const char *text, ULONG cid)
3188 { 3351 DW_FUNCTION_ADD_PARAM2(text, cid)
3189 GtkAdjustment *adj; 3352 DW_FUNCTION_RETURN(dw_spinbutton_new, HWND)
3190 GtkWidget *tmp; 3353 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3191 3354 {
3192 adj = (GtkAdjustment *)gtk_adjustment_new((float)atoi(text), -65536.0, 65536.0, 1.0, 5.0, 0.0); 3355 GtkAdjustment *adj = (GtkAdjustment *)gtk_adjustment_new((float)atoi(text), -65536.0, 65536.0, 1.0, 5.0, 0.0);
3193 tmp = gtk_spin_button_new(adj, 0, 0); 3356 GtkWidget *tmp = gtk_spin_button_new(adj, 0, 0);
3357
3194 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE); 3358 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
3195 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); 3359 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
3196 gtk_widget_show(tmp); 3360 gtk_widget_show(tmp);
3197 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adj); 3361 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adj);
3198 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)tmp); 3362 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)tmp);
3199 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3363 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3200 if(_DWDefaultFont) 3364 if(_DWDefaultFont)
3201 dw_window_set_font(tmp, _DWDefaultFont); 3365 dw_window_set_font(tmp, _DWDefaultFont);
3202 return tmp; 3366 DW_FUNCTION_RETURN_THIS(tmp);
3203 } 3367 }
3204 3368
3205 /* 3369 /*
3206 * Create a new radiobutton window (widget) to be packed. 3370 * Create a new radiobutton window (widget) to be packed.
3207 * Parameters: 3371 * Parameters:
3208 * text: The text to be display by the static text widget. 3372 * text: The text to be display by the static text widget.
3209 * id: An ID to be used with dw_window_from_id() or 0L. 3373 * id: An ID to be used with dw_window_from_id() or 0L.
3210 */ 3374 */
3211 HWND dw_radiobutton_new(const char *text, ULONG id) 3375 DW_FUNCTION_DEFINITION(dw_radiobutton_new, HWND, const char *text, ULONG cid)
3376 DW_FUNCTION_ADD_PARAM2(text, cid)
3377 DW_FUNCTION_RETURN(dw_radiobutton_new, HWND)
3378 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3212 { 3379 {
3213 GtkWidget *tmp = gtk_toggle_button_new_with_label(text); 3380 GtkWidget *tmp = gtk_toggle_button_new_with_label(text);
3214 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3381 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3215 gtk_widget_show(tmp); 3382 gtk_widget_show(tmp);
3216 3383
3217 if(_DWDefaultFont) 3384 if(_DWDefaultFont)
3218 dw_window_set_font(tmp, _DWDefaultFont); 3385 dw_window_set_font(tmp, _DWDefaultFont);
3219 return tmp; 3386 DW_FUNCTION_RETURN_THIS(tmp);
3220 } 3387 }
3221 3388
3222 /* 3389 /*
3223 * Create a new slider window (widget) to be packed. 3390 * Create a new slider window (widget) to be packed.
3224 * Parameters: 3391 * Parameters:
3225 * vertical: TRUE or FALSE if slider is vertical. 3392 * vertical: TRUE or FALSE if slider is vertical.
3226 * increments: Number of increments available. 3393 * increments: Number of increments available.
3227 * id: An ID to be used with dw_window_from_id() or 0L. 3394 * id: An ID to be used with dw_window_from_id() or 0L.
3228 */ 3395 */
3229 HWND dw_slider_new(int vertical, int increments, ULONG id) 3396 DW_FUNCTION_DEFINITION(dw_slider_new, HWND, int vertical, int increments, ULONG cid)
3230 { 3397 DW_FUNCTION_ADD_PARAM3(vertical, increments, cid)
3231 GtkWidget *tmp; 3398 DW_FUNCTION_RETURN(dw_slider_new, HWND)
3232 GtkAdjustment *adjustment; 3399 DW_FUNCTION_RESTORE_PARAM3(vertical, int, increments, int, cid, ULONG)
3233 3400
3234 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1); 3401 {
3235 tmp = gtk_scale_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment); 3402 GtkAdjustment *adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1);
3403 GtkWidget *tmp = gtk_scale_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment);
3404
3236 gtk_widget_show(tmp); 3405 gtk_widget_show(tmp);
3237 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0); 3406 gtk_scale_set_draw_value(GTK_SCALE(tmp), 0);
3238 gtk_scale_set_digits(GTK_SCALE(tmp), 0); 3407 gtk_scale_set_digits(GTK_SCALE(tmp), 0);
3239 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); 3408 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
3240 g_object_set_data(G_OBJECT(adjustment), "_dw_slider", (gpointer)tmp); 3409 g_object_set_data(G_OBJECT(adjustment), "_dw_slider", (gpointer)tmp);
3241 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3410 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3242 return tmp; 3411 DW_FUNCTION_RETURN_THIS(tmp);
3243 } 3412 }
3244 3413
3245 /* 3414 /*
3246 * Create a new scrollbar window (widget) to be packed. 3415 * Create a new scrollbar window (widget) to be packed.
3247 * Parameters: 3416 * Parameters:
3248 * vertical: TRUE or FALSE if scrollbar is vertical. 3417 * vertical: TRUE or FALSE if scrollbar is vertical.
3249 * increments: Number of increments available. 3418 * increments: Number of increments available.
3250 * id: An ID to be used with dw_window_from_id() or 0L. 3419 * id: An ID to be used with dw_window_from_id() or 0L.
3251 */ 3420 */
3252 HWND dw_scrollbar_new(int vertical, ULONG id) 3421 DW_FUNCTION_DEFINITION(dw_scrollbar_new, HWND, int vertical, ULONG cid)
3253 { 3422 DW_FUNCTION_ADD_PARAM2(vertical, cid)
3254 GtkWidget *tmp; 3423 DW_FUNCTION_RETURN(dw_scrollbar_new, HWND)
3255 GtkAdjustment *adjustment; 3424 DW_FUNCTION_RESTORE_PARAM2(vertical, int, cid, ULONG)
3256 3425 {
3257 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 1, 1, 1); 3426 GtkAdjustment *adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 1, 1, 1);
3258 tmp = gtk_scrollbar_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment); 3427 GtkWidget *tmp = gtk_scrollbar_new(vertical ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL, adjustment);
3428
3259 gtk_widget_set_can_focus(tmp, FALSE); 3429 gtk_widget_set_can_focus(tmp, FALSE);
3260 gtk_widget_show(tmp); 3430 gtk_widget_show(tmp);
3261 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment); 3431 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
3262 g_object_set_data(G_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp); 3432 g_object_set_data(G_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp);
3263 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3433 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3264 return tmp; 3434 DW_FUNCTION_RETURN_THIS(tmp);
3265 } 3435 }
3266 3436
3267 /* 3437 /*
3268 * Create a new percent bar window (widget) to be packed. 3438 * Create a new percent bar window (widget) to be packed.
3269 * Parameters: 3439 * Parameters:
3270 * id: An ID to be used with dw_window_from_id() or 0L. 3440 * id: An ID to be used with dw_window_from_id() or 0L.
3271 */ 3441 */
3272 HWND dw_percent_new(unsigned long id) 3442 DW_FUNCTION_DEFINITION(dw_percent_new, HWND, ULONG cid)
3273 { 3443 DW_FUNCTION_ADD_PARAM1(cid)
3274 GtkWidget *tmp; 3444 DW_FUNCTION_RETURN(dw_percent_new, HWND)
3275 3445 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
3276 tmp = gtk_progress_bar_new(); 3446
3447 {
3448 GtkWidget *tmp = gtk_progress_bar_new();
3277 gtk_widget_show(tmp); 3449 gtk_widget_show(tmp);
3278 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3450 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3279 return tmp; 3451 DW_FUNCTION_RETURN_THIS(tmp);
3280 } 3452 }
3281 3453
3282 /* 3454 /*
3283 * Create a new checkbox window (widget) to be packed. 3455 * Create a new checkbox window (widget) to be packed.
3284 * Parameters: 3456 * Parameters:
3285 * text: The text to be display by the static text widget. 3457 * text: The text to be display by the static text widget.
3286 * id: An ID to be used with dw_window_from_id() or 0L. 3458 * id: An ID to be used with dw_window_from_id() or 0L.
3287 */ 3459 */
3288 HWND dw_checkbox_new(const char *text, unsigned long id) 3460 DW_FUNCTION_DEFINITION(dw_checkbox_new, HWND, const char *text, ULONG cid)
3289 { 3461 DW_FUNCTION_ADD_PARAM2(text, cid)
3290 GtkWidget *tmp; 3462 DW_FUNCTION_RETURN(dw_checkbox_new, HWND)
3291 3463 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
3292 tmp = gtk_check_button_new_with_label(text); 3464 {
3465 GtkWidget *tmp = gtk_check_button_new_with_label(text);
3293 gtk_widget_show(tmp); 3466 gtk_widget_show(tmp);
3294 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 3467 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
3295 if(_DWDefaultFont) 3468 if(_DWDefaultFont)
3296 dw_window_set_font(tmp, _DWDefaultFont); 3469 dw_window_set_font(tmp, _DWDefaultFont);
3297 return tmp; 3470 DW_FUNCTION_RETURN_THIS(tmp);
3298 } 3471 }
3299 3472
3300 /* 3473 /*
3301 * Create a new listbox window (widget) to be packed. 3474 * Create a new listbox window (widget) to be packed.
3302 * Parameters: 3475 * Parameters:
3375 * (pass 0 if you use the filename param) 3548 * (pass 0 if you use the filename param)
3376 * filename: a path to a file (Bitmap on OS/2 or 3549 * filename: a path to a file (Bitmap on OS/2 or
3377 * Windows and a pixmap on Unix, pass 3550 * Windows and a pixmap on Unix, pass
3378 * NULL if you use the id param) 3551 * NULL if you use the id param)
3379 */ 3552 */
3380 void dw_window_set_bitmap(HWND handle, unsigned long id, const char *filename) 3553 DW_FUNCTION_DEFINITION(dw_window_set_bitmap, void, HWND handle, unsigned long id, const char *filename)
3554 DW_FUNCTION_ADD_PARAM3(handle, id, filename)
3555 DW_FUNCTION_NO_RETURN(dw_window_set_bitmap)
3556 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, id, ULONG, filename, const char *)
3381 { 3557 {
3382 GdkPixbuf *tmp = NULL; 3558 GdkPixbuf *tmp = NULL;
3383 int found_ext = 0; 3559 int found_ext = 0;
3384 int i; 3560 int i;
3385 3561
3386 if(!id && !filename)
3387 return;
3388
3389 if(id) 3562 if(id)
3390 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL); 3563 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL);
3391 else 3564 else
3392 { 3565 {
3393 char *file = alloca(strlen(filename) + 6); 3566 char *file = alloca(strlen(filename) + 6);
3394
3395 if(!file)
3396 return;
3397 3567
3398 strcpy(file, filename); 3568 strcpy(file, filename);
3399 3569
3400 /* check if we can read from this file (it exists and read permission) */ 3570 /* check if we can read from this file (it exists and read permission) */
3401 if(access(file, 04) != 0) 3571 if(access(file, 04) != 0)
3409 { 3579 {
3410 found_ext = 1; 3580 found_ext = 1;
3411 break; 3581 break;
3412 } 3582 }
3413 } 3583 }
3414 if(found_ext == 0) 3584 }
3415 return; 3585 if(found_ext)
3416 } 3586 tmp = gdk_pixbuf_new_from_file(file, NULL);
3417 tmp = gdk_pixbuf_new_from_file(file, NULL);
3418 } 3587 }
3419 3588
3420 if(tmp) 3589 if(tmp)
3421 { 3590 {
3422 if(GTK_IS_BUTTON(handle)) 3591 if(GTK_IS_BUTTON(handle))
3432 { 3601 {
3433 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), tmp); 3602 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), tmp);
3434 g_object_set_data(G_OBJECT(handle), "_dw_pixbuf", tmp); 3603 g_object_set_data(G_OBJECT(handle), "_dw_pixbuf", tmp);
3435 } 3604 }
3436 } 3605 }
3606 DW_FUNCTION_RETURN_NOTHING;
3437 } 3607 }
3438 3608
3439 /* 3609 /*
3440 * Sets the bitmap used for a given static window. 3610 * Sets the bitmap used for a given static window.
3441 * Parameters: 3611 * Parameters:
3445 * data: the image data 3615 * data: the image data
3446 * Bitmap on Windows and a pixmap on Unix, pass 3616 * Bitmap on Windows and a pixmap on Unix, pass
3447 * NULL if you use the id param) 3617 * NULL if you use the id param)
3448 * len: length of data 3618 * len: length of data
3449 */ 3619 */
3450 void dw_window_set_bitmap_from_data(HWND handle, unsigned long id, const char *data, int len) 3620 DW_FUNCTION_DEFINITION(dw_window_set_bitmap_from_data, void, HWND handle, unsigned long id, const char *data, int len)
3621 DW_FUNCTION_ADD_PARAM4(handle, id, data, len)
3622 DW_FUNCTION_NO_RETURN(dw_window_set_bitmap_from_data)
3623 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, id, ULONG, data, const char *, len, int)
3451 { 3624 {
3452 GdkPixbuf *tmp = NULL; 3625 GdkPixbuf *tmp = NULL;
3453
3454 if(!id && !data)
3455 return;
3456 3626
3457 if(data) 3627 if(data)
3458 { 3628 {
3459 /* 3629 /*
3460 * A real hack; create a temporary file and write the contents 3630 * A real hack; create a temporary file and write the contents
3467 { 3637 {
3468 written = write(fd, data, len); 3638 written = write(fd, data, len);
3469 close(fd); 3639 close(fd);
3470 } 3640 }
3471 /* Bail if we couldn't write full file */ 3641 /* Bail if we couldn't write full file */
3472 if(fd == -1 || written != len) 3642 if(fd != -1 && written == len)
3473 return; 3643 {
3474 3644 tmp = gdk_pixbuf_new_from_file(template, NULL);
3475 tmp = gdk_pixbuf_new_from_file(template, NULL); 3645 /* remove our temporary file */
3476 /* remove our temporary file */ 3646 unlink(template);
3477 unlink(template); 3647 }
3478 } 3648 }
3479 else if (id) 3649 else if (id)
3480 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL); 3650 tmp = _dw_find_pixbuf((HICN)id, NULL, NULL);
3481 3651
3482 if(tmp) 3652 if(tmp)
3495 { 3665 {
3496 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), tmp); 3666 gtk_image_set_from_pixbuf(GTK_IMAGE(handle), tmp);
3497 g_object_set_data(G_OBJECT(handle), "_dw_pixbuf", tmp); 3667 g_object_set_data(G_OBJECT(handle), "_dw_pixbuf", tmp);
3498 } 3668 }
3499 } 3669 }
3670 DW_FUNCTION_RETURN_NOTHING;
3500 } 3671 }
3501 3672
3502 /* 3673 /*
3503 * Sets the text used for a given window. 3674 * Sets the text used for a given window.
3504 * Parameters: 3675 * Parameters:
3505 * handle: Handle to the window. 3676 * handle: Handle to the window.
3506 * text: The text associated with a given window. 3677 * text: The text associated with a given window.
3507 */ 3678 */
3508 void dw_window_set_text(HWND handle, const char *text) 3679 DW_FUNCTION_DEFINITION(dw_window_set_text, void, HWND handle, const char *text)
3680 DW_FUNCTION_ADD_PARAM2(handle, text)
3681 DW_FUNCTION_NO_RETURN(dw_window_set_text)
3682 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
3509 { 3683 {
3510 if(GTK_IS_ENTRY(handle)) 3684 if(GTK_IS_ENTRY(handle))
3511 { 3685 {
3512 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(handle)); 3686 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(handle));
3513 if(buffer) 3687 if(buffer)
3535 if (tmp && GTK_IS_LABEL(tmp)) 3709 if (tmp && GTK_IS_LABEL(tmp))
3536 gtk_label_set_text(GTK_LABEL(tmp), text); 3710 gtk_label_set_text(GTK_LABEL(tmp), text);
3537 else /* assume groupbox */ 3711 else /* assume groupbox */
3538 gtk_frame_set_label(GTK_FRAME(handle), text && *text ? text : NULL); 3712 gtk_frame_set_label(GTK_FRAME(handle), text && *text ? text : NULL);
3539 } 3713 }
3714 DW_FUNCTION_RETURN_NOTHING;
3540 } 3715 }
3541 3716
3542 /* 3717 /*
3543 * Sets the text used for a given window's floating bubble help. 3718 * Sets the text used for a given window's floating bubble help.
3544 * Parameters: 3719 * Parameters:
3545 * handle: Handle to the window (widget). 3720 * handle: Handle to the window (widget).
3546 * bubbletext: The text in the floating bubble tooltip. 3721 * bubbletext: The text in the floating bubble tooltip.
3547 */ 3722 */
3548 void API dw_window_set_tooltip(HWND handle, const char *bubbletext) 3723 DW_FUNCTION_DEFINITION(dw_window_set_tooltip, void, HWND handle, const char *bubbletext)
3724 DW_FUNCTION_ADD_PARAM2(handle, bubbletext)
3725 DW_FUNCTION_NO_RETURN(dw_window_set_tooltip)
3726 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, bubbletext, char *)
3549 { 3727 {
3550 if(bubbletext && *bubbletext) 3728 if(bubbletext && *bubbletext)
3551 gtk_widget_set_tooltip_text(handle, bubbletext); 3729 gtk_widget_set_tooltip_text(handle, bubbletext);
3552 else 3730 else
3553 gtk_widget_set_has_tooltip(handle, FALSE); 3731 gtk_widget_set_has_tooltip(handle, FALSE);
3732 DW_FUNCTION_RETURN_NOTHING;
3554 } 3733 }
3555 3734
3556 /* 3735 /*
3557 * Gets the text used for a given window. 3736 * Gets the text used for a given window.
3558 * Parameters: 3737 * Parameters:
3559 * handle: Handle to the window. 3738 * handle: Handle to the window.
3560 * Returns: 3739 * Returns:
3561 * text: The text associsated with a given window. 3740 * text: The text associsated with a given window.
3562 */ 3741 */
3563 char *dw_window_get_text(HWND handle) 3742 DW_FUNCTION_DEFINITION(dw_window_get_text, char *, HWND handle)
3743 DW_FUNCTION_ADD_PARAM1(handle)
3744 DW_FUNCTION_RETURN(dw_window_get_text, char *)
3745 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
3564 { 3746 {
3565 const char *possible = NULL; 3747 const char *possible = NULL;
3748 char *retval = NULL;
3566 3749
3567 if(GTK_IS_ENTRY(handle)) 3750 if(GTK_IS_ENTRY(handle))
3568 { 3751 {
3569 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(handle)); 3752 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(handle));
3570 possible = gtk_entry_buffer_get_text(buffer); 3753 possible = gtk_entry_buffer_get_text(buffer);
3575 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(entry)); 3758 GtkEntryBuffer *buffer = gtk_entry_get_buffer(GTK_ENTRY(entry));
3576 possible = gtk_entry_buffer_get_text(buffer); 3759 possible = gtk_entry_buffer_get_text(buffer);
3577 } 3760 }
3578 else if(GTK_IS_LABEL(handle)) 3761 else if(GTK_IS_LABEL(handle))
3579 possible = gtk_label_get_text(GTK_LABEL(handle)); 3762 possible = gtk_label_get_text(GTK_LABEL(handle));
3580 3763 retval = strdup(possible ? possible : "");
3581 return strdup(possible ? possible : ""); 3764 DW_FUNCTION_RETURN_THIS(retval);
3582 } 3765 }
3583 3766
3584 /* 3767 /*
3585 * Disables given window (widget). 3768 * Disables given window (widget).
3586 * Parameters: 3769 * Parameters:
3587 * handle: Handle to the window. 3770 * handle: Handle to the window.
3588 */ 3771 */
3589 void dw_window_disable(HWND handle) 3772 DW_FUNCTION_DEFINITION(dw_window_disable, void, HWND handle)
3773 DW_FUNCTION_ADD_PARAM1(handle)
3774 DW_FUNCTION_NO_RETURN(dw_window_disable)
3775 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
3590 { 3776 {
3591 gtk_widget_set_sensitive(handle, FALSE); 3777 gtk_widget_set_sensitive(handle, FALSE);
3778 DW_FUNCTION_RETURN_NOTHING;
3592 } 3779 }
3593 3780
3594 /* 3781 /*
3595 * Enables given window (widget). 3782 * Enables given window (widget).
3596 * Parameters: 3783 * Parameters:
3597 * handle: Handle to the window. 3784 * handle: Handle to the window.
3598 */ 3785 */
3599 void dw_window_enable(HWND handle) 3786 DW_FUNCTION_DEFINITION(dw_window_enable, void, HWND handle)
3787 DW_FUNCTION_ADD_PARAM1(handle)
3788 DW_FUNCTION_NO_RETURN(dw_window_enable)
3789 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
3600 { 3790 {
3601 gtk_widget_set_sensitive(handle, TRUE); 3791 gtk_widget_set_sensitive(handle, TRUE);
3792 DW_FUNCTION_RETURN_NOTHING;
3602 } 3793 }
3603 3794
3604 /* 3795 /*
3605 * Gets the child window handle with specified ID. 3796 * Gets the child window handle with specified ID.
3606 * Parameters: 3797 * Parameters:
3607 * handle: Handle to the parent window. 3798 * handle: Handle to the parent window.
3608 * id: Integer ID of the child. 3799 * id: Integer ID of the child.
3609 */ 3800 */
3610 HWND API dw_window_from_id(HWND handle, int id) 3801 DW_FUNCTION_DEFINITION(dw_window_from_id, HWND, HWND handle, int id)
3611 { 3802 DW_FUNCTION_ADD_PARAM2(handle, id)
3803 DW_FUNCTION_RETURN(dw_window_from_id, HWND)
3804 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, id, int)
3805 {
3806 GtkWidget *retval = NULL;
3807
3612 if(handle && GTK_WIDGET(handle) && id) 3808 if(handle && GTK_WIDGET(handle) && id)
3613 { 3809 {
3614 GtkWidget *widget = gtk_widget_get_first_child(GTK_WIDGET(handle)); 3810 GtkWidget *widget = gtk_widget_get_first_child(GTK_WIDGET(handle));
3615 3811
3616 while(widget) 3812 while(widget)
3617 { 3813 {
3618 if(id == GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_id"))) 3814 if(id == GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "_dw_id")))
3619 return widget; 3815 {
3620 widget = gtk_widget_get_next_sibling(GTK_WIDGET(widget)); 3816 retval = widget;
3621 } 3817 widget = NULL;
3622 } 3818 }
3623 return 0; 3819 else
3820 widget = gtk_widget_get_next_sibling(GTK_WIDGET(widget));
3821 }
3822 }
3823 DW_FUNCTION_RETURN_THIS(retval);
3624 } 3824 }
3625 3825
3626 /* 3826 /*
3627 * Adds text to an MLE box and returns the current point. 3827 * Adds text to an MLE box and returns the current point.
3628 * Parameters: 3828 * Parameters:
3830 * Sets the editablity of an MLE box. 4030 * Sets the editablity of an MLE box.
3831 * Parameters: 4031 * Parameters:
3832 * handle: Handle to the MLE. 4032 * handle: Handle to the MLE.
3833 * state: TRUE if it can be edited, FALSE for readonly. 4033 * state: TRUE if it can be edited, FALSE for readonly.
3834 */ 4034 */
3835 void dw_mle_set_editable(HWND handle, int state) 4035 DW_FUNCTION_DEFINITION(dw_mle_set_editable, void, HWND handle, int state)
4036 DW_FUNCTION_ADD_PARAM2(handle, state)
4037 DW_FUNCTION_NO_RETURN(dw_mle_set_editable)
4038 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, state, int)
3836 { 4039 {
3837 if(GTK_IS_SCROLLED_WINDOW(handle)) 4040 if(GTK_IS_SCROLLED_WINDOW(handle))
3838 { 4041 {
3839 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 4042 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
3840 4043
3841 if(tmp && GTK_IS_TEXT_VIEW(tmp)) 4044 if(tmp && GTK_IS_TEXT_VIEW(tmp))
3842 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state); 4045 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state);
3843 } 4046 }
4047 DW_FUNCTION_RETURN_NOTHING;
3844 } 4048 }
3845 4049
3846 /* 4050 /*
3847 * Sets the word wrap state of an MLE box. 4051 * Sets the word wrap state of an MLE box.
3848 * Parameters: 4052 * Parameters:
3849 * handle: Handle to the MLE. 4053 * handle: Handle to the MLE.
3850 * state: TRUE if it wraps, FALSE if it doesn't. 4054 * state: TRUE if it wraps, FALSE if it doesn't.
3851 */ 4055 */
3852 void dw_mle_set_word_wrap(HWND handle, int state) 4056 DW_FUNCTION_DEFINITION(dw_mle_set_word_wrap, void, HWND handle, int state)
4057 DW_FUNCTION_ADD_PARAM2(handle, state)
4058 DW_FUNCTION_NO_RETURN(dw_mle_set_word_wrap)
4059 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, state, int)
3853 { 4060 {
3854 if(GTK_IS_SCROLLED_WINDOW(handle)) 4061 if(GTK_IS_SCROLLED_WINDOW(handle))
3855 { 4062 {
3856 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 4063 GtkWidget *tmp = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
3857 4064
3858 if(tmp && GTK_IS_TEXT_VIEW(tmp)) 4065 if(tmp && GTK_IS_TEXT_VIEW(tmp))
3859 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), state ? GTK_WRAP_WORD : GTK_WRAP_NONE); 4066 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), state ? GTK_WRAP_WORD : GTK_WRAP_NONE);
3860 } 4067 }
4068 DW_FUNCTION_RETURN_NOTHING;
3861 } 4069 }
3862 4070
3863 /* 4071 /*
3864 * Sets the word auto complete state of an MLE box. 4072 * Sets the word auto complete state of an MLE box.
3865 * Parameters: 4073 * Parameters:
4007 /* 4215 /*
4008 * Returns the position of the slider. 4216 * Returns the position of the slider.
4009 * Parameters: 4217 * Parameters:
4010 * handle: Handle to the slider to be queried. 4218 * handle: Handle to the slider to be queried.
4011 */ 4219 */
4012 unsigned int dw_slider_get_pos(HWND handle) 4220 DW_FUNCTION_DEFINITION(dw_slider_get_pos, unsigned int, HWND handle)
4221 DW_FUNCTION_ADD_PARAM1(handle)
4222 DW_FUNCTION_RETURN(dw_slider_get_pos, unsigned int)
4223 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
4013 { 4224 {
4014 int val = 0; 4225 int val = 0;
4015 GtkAdjustment *adjustment; 4226 GtkAdjustment *adjustment;
4016 4227
4017 if(!handle) 4228 if(handle)
4018 return 0; 4229 {
4019 4230 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
4020 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment"); 4231 if(adjustment)
4021 if(adjustment) 4232 {
4022 { 4233 int max = _dw_round_value(gtk_adjustment_get_upper(adjustment)) - 1;
4023 int max = _round_value(gtk_adjustment_get_upper(adjustment)) - 1; 4234 int thisval = _dw_round_value(gtk_adjustment_get_value(adjustment));
4024 int thisval = _round_value(gtk_adjustment_get_value(adjustment)); 4235
4025 4236 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL)
4026 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL) 4237 val = max - thisval;
4027 val = max - thisval; 4238 else
4028 else 4239 val = thisval;
4029 val = thisval; 4240 }
4030 } 4241 }
4031 return val; 4242 DW_FUNCTION_RETURN_THIS(val);
4032 } 4243 }
4033 4244
4034 /* 4245 /*
4035 * Sets the slider position. 4246 * Sets the slider position.
4036 * Parameters: 4247 * Parameters:
4037 * handle: Handle to the slider to be set. 4248 * handle: Handle to the slider to be set.
4038 * position: Position of the slider withing the range. 4249 * position: Position of the slider withing the range.
4039 */ 4250 */
4040 void dw_slider_set_pos(HWND handle, unsigned int position) 4251 DW_FUNCTION_DEFINITION(dw_slider_set_pos, void, HWND handle, unsigned int position)
4252 DW_FUNCTION_ADD_PARAM2(handle, position)
4253 DW_FUNCTION_NO_RETURN(dw_slider_set_pos)
4254 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, unsigned int)
4041 { 4255 {
4042 GtkAdjustment *adjustment; 4256 GtkAdjustment *adjustment;
4043 4257
4044 if(!handle) 4258 if(handle)
4045 return; 4259 {
4046 4260 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
4047 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment"); 4261 if(adjustment)
4048 if(adjustment) 4262 {
4049 { 4263 int max = _dw_round_value(gtk_adjustment_get_upper(adjustment)) - 1;
4050 int max = _round_value(gtk_adjustment_get_upper(adjustment)) - 1; 4264
4051 4265 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL)
4052 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_VERTICAL) 4266 gtk_adjustment_set_value(adjustment, (gfloat)(max - position));
4053 gtk_adjustment_set_value(adjustment, (gfloat)(max - position)); 4267 else
4054 else 4268 gtk_adjustment_set_value(adjustment, (gfloat)position);
4055 gtk_adjustment_set_value(adjustment, (gfloat)position); 4269 }
4056 } 4270 }
4271 DW_FUNCTION_RETURN_NOTHING;
4057 } 4272 }
4058 4273
4059 /* 4274 /*
4060 * Returns the position of the scrollbar. 4275 * Returns the position of the scrollbar.
4061 * Parameters: 4276 * Parameters:
4062 * handle: Handle to the scrollbar to be queried. 4277 * handle: Handle to the scrollbar to be queried.
4063 */ 4278 */
4064 unsigned int dw_scrollbar_get_pos(HWND handle) 4279 DW_FUNCTION_DEFINITION(dw_scrollbar_get_pos, unsigned int, HWND handle)
4280 DW_FUNCTION_ADD_PARAM1(handle)
4281 DW_FUNCTION_RETURN(dw_scrollbar_get_pos, unsigned int)
4282 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
4065 { 4283 {
4066 int val = 0; 4284 int val = 0;
4067 GtkAdjustment *adjustment; 4285 GtkAdjustment *adjustment;
4068 4286
4069 if(!handle) 4287 if(handle)
4070 return 0; 4288 {
4071 4289 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment");
4072 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment"); 4290 if(adjustment)
4073 if(adjustment) 4291 val = _dw_round_value(gtk_adjustment_get_value(adjustment));
4074 val = _round_value(gtk_adjustment_get_value(adjustment)); 4292 }
4075 return val; 4293 DW_FUNCTION_RETURN_THIS(val);
4076 } 4294 }
4077 4295
4078 /* 4296 /*
4079 * Sets the scrollbar position. 4297 * Sets the scrollbar position.
4080 * Parameters: 4298 * Parameters:
4081 * handle: Handle to the scrollbar to be set. 4299 * handle: Handle to the scrollbar to be set.
4082 * position: Position of the scrollbar withing the range. 4300 * position: Position of the scrollbar withing the range.
4083 */ 4301 */
4084 void dw_scrollbar_set_pos(HWND handle, unsigned int position) 4302 DW_FUNCTION_DEFINITION(dw_scrollbar_set_pos, void, HWND handle, unsigned int position)
4303 DW_FUNCTION_ADD_PARAM2(handle, position)
4304 DW_FUNCTION_NO_RETURN(dw_scrollbar_set_pos)
4305 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, unsigned int)
4306
4085 { 4307 {
4086 GtkAdjustment *adjustment; 4308 GtkAdjustment *adjustment;
4087 4309
4088 if(!handle) 4310 if(handle)
4089 return; 4311 {
4090 4312 if((adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment")))
4091 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment"); 4313 {
4092 if(adjustment) 4314 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(1));
4093 { 4315 gtk_adjustment_set_value(adjustment, (gfloat)position);
4094 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(1)); 4316 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(0));
4095 gtk_adjustment_set_value(adjustment, (gfloat)position); 4317 }
4096 g_object_set_data(G_OBJECT(adjustment), "_dw_suppress_value_changed_event", GINT_TO_POINTER(0)); 4318 }
4097 } 4319 DW_FUNCTION_RETURN_NOTHING;
4098 } 4320 }
4099 4321
4100 /* 4322 /*
4101 * Sets the scrollbar range. 4323 * Sets the scrollbar range.
4102 * Parameters: 4324 * Parameters:
4103 * handle: Handle to the scrollbar to be set. 4325 * handle: Handle to the scrollbar to be set.
4104 * range: Maximum range value. 4326 * range: Maximum range value.
4105 * visible: Visible area relative to the range. 4327 * visible: Visible area relative to the range.
4106 */ 4328 */
4107 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible) 4329 DW_FUNCTION_DEFINITION(dw_scrollbar_set_range, void, HWND handle, unsigned int range, unsigned int visible)
4330 DW_FUNCTION_ADD_PARAM3(handle, range, visible)
4331 DW_FUNCTION_NO_RETURN(dw_scrollbar_set_range)
4332 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, range, unsigned int, visible, unsigned int)
4108 { 4333 {
4109 GtkAdjustment *adjustment; 4334 GtkAdjustment *adjustment;
4110 4335
4111 if(!handle) 4336 if(handle)
4112 return; 4337 {
4113 4338 if((adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment")))
4114 adjustment = (GtkAdjustment *)g_object_get_data(G_OBJECT(handle), "_dw_adjustment"); 4339 {
4115 if(adjustment) 4340 gtk_adjustment_set_upper(adjustment, (gdouble)range);
4116 { 4341 gtk_adjustment_set_page_increment(adjustment,(gdouble)visible);
4117 gtk_adjustment_set_upper(adjustment, (gdouble)range); 4342 gtk_adjustment_set_page_size(adjustment, (gdouble)visible);
4118 gtk_adjustment_set_page_increment(adjustment,(gdouble)visible); 4343 }
4119 gtk_adjustment_set_page_size(adjustment, (gdouble)visible); 4344 }
4120 } 4345 DW_FUNCTION_RETURN_NOTHING;
4121 } 4346 }
4122 4347
4123 /* 4348 /*
4124 * Sets the spinbutton value. 4349 * Sets the spinbutton value.
4125 * Parameters: 4350 * Parameters:
4126 * handle: Handle to the spinbutton to be set. 4351 * handle: Handle to the spinbutton to be set.
4127 * position: Current value of the spinbutton. 4352 * position: Current value of the spinbutton.
4128 */ 4353 */
4129 void dw_spinbutton_set_pos(HWND handle, long position) 4354 DW_FUNCTION_DEFINITION(dw_spinbutton_set_pos, void, HWND handle, long position)
4355 DW_FUNCTION_ADD_PARAM2(handle, position)
4356 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_pos)
4357 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, position, long)
4130 { 4358 {
4131 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position); 4359 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
4360 DW_FUNCTION_RETURN_NOTHING;
4132 } 4361 }
4133 4362
4134 /* 4363 /*
4135 * Sets the spinbutton limits. 4364 * Sets the spinbutton limits.
4136 * Parameters: 4365 * Parameters:
4137 * handle: Handle to the spinbutton to be set. 4366 * handle: Handle to the spinbutton to be set.
4138 * position: Current value of the spinbutton. 4367 * position: Current value of the spinbutton.
4139 * position: Current value of the spinbutton. 4368 * position: Current value of the spinbutton.
4140 */ 4369 */
4141 void dw_spinbutton_set_limits(HWND handle, long upper, long lower) 4370 DW_FUNCTION_DEFINITION(dw_spinbutton_set_limits, void, HWND handle, long upper, long lower)
4371 DW_FUNCTION_ADD_PARAM3(handle, upper, lower)
4372 DW_FUNCTION_NO_RETURN(dw_spinbutton_set_limits)
4373 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, upper, long, lower, long)
4142 { 4374 {
4143 long curval; 4375 long curval;
4144 GtkAdjustment *adj; 4376 GtkAdjustment *adj;
4145 4377
4146 curval = dw_spinbutton_get_pos(handle); 4378 curval = dw_spinbutton_get_pos(handle);
4149 /* 4381 /*
4150 * Set our internal relationships between the adjustment and the spinbutton 4382 * Set our internal relationships between the adjustment and the spinbutton
4151 */ 4383 */
4152 g_object_set_data(G_OBJECT(handle), "_dw_adjustment", (gpointer)adj); 4384 g_object_set_data(G_OBJECT(handle), "_dw_adjustment", (gpointer)adj);
4153 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)handle); 4385 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)handle);
4386 DW_FUNCTION_RETURN_NOTHING;
4154 } 4387 }
4155 4388
4156 /* 4389 /*
4157 * Sets the entryfield character limit. 4390 * Sets the entryfield character limit.
4158 * Parameters: 4391 * Parameters:
4159 * handle: Handle to the spinbutton to be set. 4392 * handle: Handle to the spinbutton to be set.
4160 * limit: Number of characters the entryfield will take. 4393 * limit: Number of characters the entryfield will take.
4161 */ 4394 */
4162 void dw_entryfield_set_limit(HWND handle, ULONG limit) 4395 DW_FUNCTION_DEFINITION(dw_entryfield_set_limit, void, HWND handle, ULONG limit)
4396 DW_FUNCTION_ADD_PARAM2(handle, limit)
4397 DW_FUNCTION_NO_RETURN(dw_entryfield_set_limit)
4398 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, limit, ULONG)
4163 { 4399 {
4164 gtk_entry_set_max_length(GTK_ENTRY(handle), limit); 4400 gtk_entry_set_max_length(GTK_ENTRY(handle), limit);
4401 DW_FUNCTION_RETURN_NOTHING;
4165 } 4402 }
4166 4403
4167 /* 4404 /*
4168 * Returns the current value of the spinbutton. 4405 * Returns the current value of the spinbutton.
4169 * Parameters: 4406 * Parameters:
4170 * handle: Handle to the spinbutton to be queried. 4407 * handle: Handle to the spinbutton to be queried.
4171 */ 4408 */
4172 long dw_spinbutton_get_pos(HWND handle) 4409 DW_FUNCTION_DEFINITION(dw_spinbutton_get_pos, long, HWND handle)
4173 { 4410 DW_FUNCTION_ADD_PARAM1(handle)
4174 return (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle)); 4411 DW_FUNCTION_RETURN(dw_spinbutton_get_pos, long)
4412 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
4413 {
4414 long retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
4415 DW_FUNCTION_RETURN_THIS(retval);
4175 } 4416 }
4176 4417
4177 /* 4418 /*
4178 * Returns the state of the checkbox. 4419 * Returns the state of the checkbox.
4179 * Parameters: 4420 * Parameters:
4180 * handle: Handle to the checkbox to be queried. 4421 * handle: Handle to the checkbox to be queried.
4181 */ 4422 */
4182 int dw_checkbox_get(HWND handle) 4423 DW_FUNCTION_DEFINITION(dw_checkbox_get, int, HWND handle)
4183 { 4424 DW_FUNCTION_ADD_PARAM1(handle)
4184 if(GTK_IS_TOGGLE_BUTTON(handle)) 4425 DW_FUNCTION_RETURN(dw_checkbox_get, int)
4185 return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(handle)); 4426 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
4186 return gtk_check_button_get_active(GTK_CHECK_BUTTON(handle)); 4427 {
4428 int retval = 0;
4429
4430 if(handle)
4431 {
4432 if(GTK_IS_TOGGLE_BUTTON(handle))
4433 retval = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(handle));
4434 retval = gtk_check_button_get_active(GTK_CHECK_BUTTON(handle));
4435 }
4436 DW_FUNCTION_RETURN_THIS(retval);
4187 } 4437 }
4188 4438
4189 /* 4439 /*
4190 * Sets the state of the checkbox. 4440 * Sets the state of the checkbox.
4191 * Parameters: 4441 * Parameters:
4192 * handle: Handle to the checkbox to be queried. 4442 * handle: Handle to the checkbox to be queried.
4193 * value: TRUE for checked, FALSE for unchecked. 4443 * value: TRUE for checked, FALSE for unchecked.
4194 */ 4444 */
4195 void dw_checkbox_set(HWND handle, int value) 4445 DW_FUNCTION_DEFINITION(dw_checkbox_set, void, HWND handle, int value)
4196 { 4446 DW_FUNCTION_ADD_PARAM2(handle, value)
4197 if(GTK_IS_TOGGLE_BUTTON(handle)) 4447 DW_FUNCTION_NO_RETURN(dw_checkbox_set)
4198 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value); 4448 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, value, int)
4199 else 4449 {
4200 gtk_check_button_set_active(GTK_CHECK_BUTTON(handle), value); 4450 if(handle)
4451 {
4452 if(GTK_IS_TOGGLE_BUTTON(handle))
4453 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
4454 else
4455 gtk_check_button_set_active(GTK_CHECK_BUTTON(handle), value);
4456 }
4457 DW_FUNCTION_RETURN_NOTHING;
4201 } 4458 }
4202 4459
4203 /* 4460 /*
4204 * Inserts an item into a tree window (widget) after another item. 4461 * Inserts an item into a tree window (widget) after another item.
4205 * Parameters: 4462 * Parameters:
4769 * handle: Handle to the container to be configured. 5026 * handle: Handle to the container to be configured.
4770 * flags: An array of unsigned longs with column flags. 5027 * flags: An array of unsigned longs with column flags.
4771 * titles: An array of strings with column text titles. 5028 * titles: An array of strings with column text titles.
4772 * count: The number of columns (this should match the arrays). 5029 * count: The number of columns (this should match the arrays).
4773 */ 5030 */
4774 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) 5031 DW_FUNCTION_DEFINITION(dw_filesystem_setup, int, HWND handle, unsigned long *flags, char **titles, int count)
5032 DW_FUNCTION_ADD_PARAM4(handle, flags, titles, count)
5033 DW_FUNCTION_RETURN(dw_filesystem_setup, int)
5034 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, flags, unsigned long *, titles, char **, count, int)
4775 { 5035 {
4776 char **newtitles = malloc(sizeof(char *) * (count + 1)); 5036 char **newtitles = malloc(sizeof(char *) * (count + 1));
4777 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1)); 5037 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
4778 char *coltitle = (char *)g_object_get_data(G_OBJECT(handle), "_dw_coltitle"); 5038 char *coltitle = (char *)g_object_get_data(G_OBJECT(handle), "_dw_coltitle");
5039 int retval;
4779 5040
4780 newtitles[0] = coltitle ? coltitle : "Filename"; 5041 newtitles[0] = coltitle ? coltitle : "Filename";
4781 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; 5042 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
4782 5043
4783 memcpy(&newtitles[1], titles, sizeof(char *) * count); 5044 memcpy(&newtitles[1], titles, sizeof(char *) * count);
4784 memcpy(&newflags[1], flags, sizeof(unsigned long) * count); 5045 memcpy(&newflags[1], flags, sizeof(unsigned long) * count);
4785 5046
4786 _dw_container_setup_int(handle, newflags, newtitles, count + 1, 1, 1); 5047 retval = _dw_container_setup_int(handle, newflags, newtitles, count + 1, 1, 1);
4787 5048
4788 if(coltitle) 5049 if(coltitle)
4789 { 5050 {
4790 g_object_set_data(G_OBJECT(handle), "_dw_coltitle", NULL); 5051 g_object_set_data(G_OBJECT(handle), "_dw_coltitle", NULL);
4791 free(coltitle); 5052 free(coltitle);
4792 } 5053 }
4793 if ( newtitles) free(newtitles); 5054 if(newtitles)
4794 if ( newflags ) free(newflags); 5055 free(newtitles);
4795 return DW_ERROR_NONE; 5056 if(newflags)
5057 free(newflags);
5058 DW_FUNCTION_RETURN_THIS(retval);
4796 } 5059 }
4797 5060
4798 /* 5061 /*
4799 * Obtains an icon from a module (or header in GTK). 5062 * Obtains an icon from a module (or header in GTK).
4800 * Parameters: 5063 * Parameters:
5262 * Parameters: 5525 * Parameters:
5263 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5526 * pointer: Pointer to the allocated memory in dw_container_alloc().
5264 * row: Zero based row of data being set. 5527 * row: Zero based row of data being set.
5265 * title: String title of the item. 5528 * title: String title of the item.
5266 */ 5529 */
5267 void dw_container_set_row_title(void *pointer, int row, const char *title) 5530 DW_FUNCTION_DEFINITION(dw_container_set_row_title, void, void *pointer, int row, const char *title)
5531 DW_FUNCTION_ADD_PARAM3(pointer, row, title)
5532 DW_FUNCTION_NO_RETURN(dw_container_set_row_title)
5533 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, title, char *)
5268 { 5534 {
5269 _dw_container_set_row_data_int(pointer, pointer, row, _DW_DATA_TYPE_STRING, (void *)title); 5535 _dw_container_set_row_data_int(pointer, pointer, row, _DW_DATA_TYPE_STRING, (void *)title);
5536 DW_FUNCTION_RETURN_NOTHING;
5270 } 5537 }
5271 5538
5272 /* 5539 /*
5273 * Changes the title of a row already inserted in the container. 5540 * Changes the title of a row already inserted in the container.
5274 * Parameters: 5541 * Parameters:
5275 * handle: Handle to window (widget) of container. 5542 * handle: Handle to window (widget) of container.
5276 * row: Zero based row of data being set. 5543 * row: Zero based row of data being set.
5277 * title: String title of the item. 5544 * title: String title of the item.
5278 */ 5545 */
5279 void dw_container_change_row_title(HWND handle, int row, const char *title) 5546 DW_FUNCTION_DEFINITION(dw_container_change_row_title, void, HWND handle, int row, const char *title)
5547 DW_FUNCTION_ADD_PARAM3(handle, row, title)
5548 DW_FUNCTION_NO_RETURN(dw_container_change_row_title)
5549 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, title, char *)
5280 { 5550 {
5281 _dw_container_set_row_data_int(handle, NULL, row, _DW_DATA_TYPE_STRING, (void *)title); 5551 _dw_container_set_row_data_int(handle, NULL, row, _DW_DATA_TYPE_STRING, (void *)title);
5552 DW_FUNCTION_RETURN_NOTHING;
5282 } 5553 }
5283 5554
5284 /* 5555 /*
5285 * Sets the data of a row in the container. 5556 * Sets the data of a row in the container.
5286 * Parameters: 5557 * Parameters:
5287 * pointer: Pointer to the allocated memory in dw_container_alloc(). 5558 * pointer: Pointer to the allocated memory in dw_container_alloc().
5288 * row: Zero based row of data being set. 5559 * row: Zero based row of data being set.
5289 * data: Data pointer. 5560 * data: Data pointer.
5290 */ 5561 */
5291 void dw_container_set_row_data(void *pointer, int row, void *data) 5562 DW_FUNCTION_DEFINITION(dw_container_set_row_data, void, void *pointer, int row, void *data)
5563 DW_FUNCTION_ADD_PARAM3(pointer, row, data)
5564 DW_FUNCTION_NO_RETURN(dw_container_set_row_data)
5565 DW_FUNCTION_RESTORE_PARAM3(pointer, void *, row, int, data, void *)
5292 { 5566 {
5293 _dw_container_set_row_data_int(pointer, pointer, row, _DW_DATA_TYPE_POINTER, data); 5567 _dw_container_set_row_data_int(pointer, pointer, row, _DW_DATA_TYPE_POINTER, data);
5568 DW_FUNCTION_RETURN_NOTHING;
5294 } 5569 }
5295 5570
5296 /* 5571 /*
5297 * Changes the data of a row already inserted in the container. 5572 * Changes the data of a row already inserted in the container.
5298 * Parameters: 5573 * Parameters:
5299 * handle: Handle to window (widget) of container. 5574 * handle: Handle to window (widget) of container.
5300 * row: Zero based row of data being set. 5575 * row: Zero based row of data being set.
5301 * data: Data pointer. 5576 * data: Data pointer.
5302 */ 5577 */
5303 void dw_container_change_row_data(HWND handle, int row, void *data) 5578 DW_FUNCTION_DEFINITION(dw_container_change_row_data, void, HWND handle, int row, void *data)
5579 DW_FUNCTION_ADD_PARAM3(handle, row, data)
5580 DW_FUNCTION_NO_RETURN(dw_container_change_row_data)
5581 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, row, int, data, void *)
5304 { 5582 {
5305 _dw_container_set_row_data_int(handle, NULL, row, _DW_DATA_TYPE_POINTER, data); 5583 _dw_container_set_row_data_int(handle, NULL, row, _DW_DATA_TYPE_POINTER, data);
5584 DW_FUNCTION_RETURN_NOTHING;
5306 } 5585 }
5307 5586
5308 /* 5587 /*
5309 * Sets the title of a row in the container. 5588 * Sets the title of a row in the container.
5310 * Parameters: 5589 * Parameters:
5321 * Removes the first x rows from a container. 5600 * Removes the first x rows from a container.
5322 * Parameters: 5601 * Parameters:
5323 * handle: Handle to the window (widget) to be deleted from. 5602 * handle: Handle to the window (widget) to be deleted from.
5324 * rowcount: The number of rows to be deleted. 5603 * rowcount: The number of rows to be deleted.
5325 */ 5604 */
5326 void dw_container_delete(HWND handle, int rowcount) 5605 DW_FUNCTION_DEFINITION(dw_container_delete, void, HWND handle, int rowcount)
5606 DW_FUNCTION_ADD_PARAM2(handle, rowcount)
5607 DW_FUNCTION_NO_RETURN(dw_container_delete)
5608 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, rowcount, int)
5327 { 5609 {
5328 GtkWidget *cont; 5610 GtkWidget *cont;
5329 GtkListStore *store = NULL; 5611 GtkListStore *store = NULL;
5330 5612
5331 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 5613 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5352 else 5634 else
5353 rows -= rowcount; 5635 rows -= rowcount;
5354 5636
5355 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rows)); 5637 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(rows));
5356 } 5638 }
5639 DW_FUNCTION_RETURN_NOTHING;
5357 } 5640 }
5358 5641
5359 /* 5642 /*
5360 * Removes all rows from a container. 5643 * Removes all rows from a container.
5361 * Parameters: 5644 * Parameters:
5362 * handle: Handle to the window (widget) to be cleared. 5645 * handle: Handle to the window (widget) to be cleared.
5363 * redraw: TRUE to cause the container to redraw immediately. 5646 * redraw: TRUE to cause the container to redraw immediately.
5364 */ 5647 */
5365 void dw_container_clear(HWND handle, int redraw) 5648 DW_FUNCTION_DEFINITION(dw_container_clear, void, HWND handle, DW_UNUSED(int redraw))
5649 DW_FUNCTION_ADD_PARAM2(handle, redraw)
5650 DW_FUNCTION_NO_RETURN(dw_container_clear)
5651 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, DW_UNUSED(redraw), int)
5366 { 5652 {
5367 GtkWidget *cont; 5653 GtkWidget *cont;
5368 GtkListStore *store = NULL; 5654 GtkListStore *store = NULL;
5369 5655
5370 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 5656 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5378 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(0)); 5664 g_object_set_data(G_OBJECT(cont), "_dw_rowcount", GINT_TO_POINTER(0));
5379 g_object_set_data(G_OBJECT(cont), "_dw_insertpos", GINT_TO_POINTER(0)); 5665 g_object_set_data(G_OBJECT(cont), "_dw_insertpos", GINT_TO_POINTER(0));
5380 5666
5381 gtk_list_store_clear(store); 5667 gtk_list_store_clear(store);
5382 } 5668 }
5669 DW_FUNCTION_RETURN_NOTHING;
5383 } 5670 }
5384 5671
5385 /* 5672 /*
5386 * Scrolls container up or down. 5673 * Scrolls container up or down.
5387 * Parameters: 5674 * Parameters:
5388 * handle: Handle to the window (widget) to be scrolled. 5675 * handle: Handle to the window (widget) to be scrolled.
5389 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or 5676 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
5390 * DW_SCROLL_BOTTOM. (rows is ignored for last two) 5677 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
5391 * rows: The number of rows to be scrolled. 5678 * rows: The number of rows to be scrolled.
5392 */ 5679 */
5393 void dw_container_scroll(HWND handle, int direction, long rows) 5680 DW_FUNCTION_DEFINITION(dw_container_scroll, void, HWND handle, int direction, long rows)
5681 DW_FUNCTION_ADD_PARAM3(handle, direction, rows)
5682 DW_FUNCTION_NO_RETURN(dw_container_scroll)
5683 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, direction, int, rows, long)
5394 { 5684 {
5395 GtkWidget *cont; 5685 GtkWidget *cont;
5396 5686
5397 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 5687 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5398 5688
5408 gdouble upper = gtk_adjustment_get_upper(adjust); 5698 gdouble upper = gtk_adjustment_get_upper(adjust);
5409 gdouble lower = gtk_adjustment_get_lower(adjust); 5699 gdouble lower = gtk_adjustment_get_lower(adjust);
5410 gdouble change; 5700 gdouble change;
5411 5701
5412 /* Safety check */ 5702 /* Safety check */
5413 if(rowcount < 1) 5703 if(rowcount > 0)
5414 return;
5415
5416 change = ((gdouble)rows/(gdouble)rowcount) * (upper - lower);
5417
5418 switch(direction)
5419 { 5704 {
5420 case DW_SCROLL_TOP: 5705 change = ((gdouble)rows/(gdouble)rowcount) * (upper - lower);
5421 { 5706
5422 gtk_adjustment_set_value(adjust, lower); 5707 switch(direction)
5423 break; 5708 {
5424 } 5709 case DW_SCROLL_TOP:
5425 case DW_SCROLL_BOTTOM: 5710 {
5426 { 5711 gtk_adjustment_set_value(adjust, lower);
5427 gtk_adjustment_set_value(adjust, upper); 5712 break;
5428 break; 5713 }
5429 } 5714 case DW_SCROLL_BOTTOM:
5430 case DW_SCROLL_UP: 5715 {
5431 { 5716 gtk_adjustment_set_value(adjust, upper);
5432 gdouble newpos = currpos - change; 5717 break;
5433 if(newpos < lower) 5718 }
5434 { 5719 case DW_SCROLL_UP:
5435 newpos = lower; 5720 {
5436 } 5721 gdouble newpos = currpos - change;
5437 gtk_adjustment_set_value(adjust, newpos); 5722 if(newpos < lower)
5438 break; 5723 {
5439 } 5724 newpos = lower;
5440 case DW_SCROLL_DOWN: 5725 }
5441 { 5726 gtk_adjustment_set_value(adjust, newpos);
5442 gdouble newpos = currpos + change; 5727 break;
5443 if(newpos > upper) 5728 }
5444 { 5729 case DW_SCROLL_DOWN:
5445 newpos = upper; 5730 {
5446 } 5731 gdouble newpos = currpos + change;
5447 gtk_adjustment_set_value(adjust, newpos); 5732 if(newpos > upper)
5448 break; 5733 {
5449 } 5734 newpos = upper;
5735 }
5736 gtk_adjustment_set_value(adjust, newpos);
5737 break;
5738 }
5739 }
5450 } 5740 }
5451 } 5741 }
5452 } 5742 }
5743 DW_FUNCTION_RETURN_NOTHING;
5453 } 5744 }
5454 5745
5455 /* 5746 /*
5456 * Starts a new query of a container. 5747 * Starts a new query of a container.
5457 * Parameters: 5748 * Parameters:
5458 * handle: Handle to the window (widget) to be queried. 5749 * handle: Handle to the window (widget) to be queried.
5459 * flags: If this parameter is DW_CRA_SELECTED it will only 5750 * flags: If this parameter is DW_CRA_SELECTED it will only
5460 * return items that are currently selected. Otherwise 5751 * return items that are currently selected. Otherwise
5461 * it will return all records in the container. 5752 * it will return all records in the container.
5462 */ 5753 */
5463 char *dw_container_query_start(HWND handle, unsigned long flags) 5754 DW_FUNCTION_DEFINITION(dw_container_query_start, char *, HWND handle, unsigned long flags)
5755 DW_FUNCTION_ADD_PARAM2(handle, flags)
5756 DW_FUNCTION_RETURN(dw_container_query_start, char *)
5757 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
5464 { 5758 {
5465 GtkWidget *cont; 5759 GtkWidget *cont;
5466 GtkListStore *store = NULL; 5760 GtkListStore *store = NULL;
5467 char *retval = NULL; 5761 char *retval = NULL;
5468 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING; 5762 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING;
5535 { 5829 {
5536 char *temp = retval; 5830 char *temp = retval;
5537 retval = strdup(temp); 5831 retval = strdup(temp);
5538 g_free(temp); 5832 g_free(temp);
5539 } 5833 }
5540 return retval; 5834 DW_FUNCTION_RETURN_THIS(retval);
5541 } 5835 }
5542 5836
5543 /* 5837 /*
5544 * Continues an existing query of a container. 5838 * Continues an existing query of a container.
5545 * Parameters: 5839 * Parameters:
5546 * handle: Handle to the window (widget) to be queried. 5840 * handle: Handle to the window (widget) to be queried.
5547 * flags: If this parameter is DW_CRA_SELECTED it will only 5841 * flags: If this parameter is DW_CRA_SELECTED it will only
5548 * return items that are currently selected. Otherwise 5842 * return items that are currently selected. Otherwise
5549 * it will return all records in the container. 5843 * it will return all records in the container.
5550 */ 5844 */
5551 char *dw_container_query_next(HWND handle, unsigned long flags) 5845 DW_FUNCTION_DEFINITION(dw_container_query_next, char *, HWND handle, unsigned long flags)
5846 DW_FUNCTION_ADD_PARAM2(handle, flags)
5847 DW_FUNCTION_RETURN(dw_container_query_next, char *)
5848 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, flags, unsigned long)
5552 { 5849 {
5553 GtkWidget *cont; 5850 GtkWidget *cont;
5554 GtkListStore *store = NULL; 5851 GtkListStore *store = NULL;
5555 char *retval = NULL; 5852 char *retval = NULL;
5556 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING; 5853 int type = flags & DW_CR_RETDATA ? _DW_DATA_TYPE_POINTER : _DW_DATA_TYPE_STRING;
5618 { 5915 {
5619 char *temp = retval; 5916 char *temp = retval;
5620 retval = strdup(temp); 5917 retval = strdup(temp);
5621 g_free(temp); 5918 g_free(temp);
5622 } 5919 }
5623 return retval; 5920 DW_FUNCTION_RETURN_THIS(retval);
5624 } 5921 }
5625 5922
5626 int _find_iter(GtkListStore *store, GtkTreeIter *iter, void *data, int textcomp) 5923 int _find_iter(GtkListStore *store, GtkTreeIter *iter, void *data, int textcomp)
5627 { 5924 {
5628 int z, rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); 5925 int z, rows = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
5645 } 5942 }
5646 } 5943 }
5647 return retval; 5944 return retval;
5648 } 5945 }
5649 5946
5650 void _dw_container_cursor(HWND handle, void *data, int textcomp) 5947 void _dw_container_cursor_int(HWND handle, void *data, int textcomp)
5651 { 5948 {
5652 GtkWidget *cont; 5949 GtkWidget *cont;
5653 GtkListStore *store = NULL; 5950 GtkListStore *store = NULL;
5654 5951
5655 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 5952 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5679 * Cursors the item with the text speficied, and scrolls to that item. 5976 * Cursors the item with the text speficied, and scrolls to that item.
5680 * Parameters: 5977 * Parameters:
5681 * handle: Handle to the window (widget) to be queried. 5978 * handle: Handle to the window (widget) to be queried.
5682 * text: Text usually returned by dw_container_query(). 5979 * text: Text usually returned by dw_container_query().
5683 */ 5980 */
5684 void dw_container_cursor(HWND handle, const char *text) 5981 DW_FUNCTION_DEFINITION(dw_container_cursor, void, HWND handle, const char *text)
5685 { 5982 DW_FUNCTION_ADD_PARAM2(handle, text)
5686 _dw_container_cursor(handle, (void *)text, TRUE); 5983 DW_FUNCTION_NO_RETURN(dw_container_cursor)
5984 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
5985 {
5986 _dw_container_cursor_int(handle, (void *)text, TRUE);
5987 DW_FUNCTION_RETURN_NOTHING;
5687 } 5988 }
5688 5989
5689 /* 5990 /*
5690 * Cursors the item with the text speficied, and scrolls to that item. 5991 * Cursors the item with the text speficied, and scrolls to that item.
5691 * Parameters: 5992 * Parameters:
5692 * handle: Handle to the window (widget) to be queried. 5993 * handle: Handle to the window (widget) to be queried.
5693 * text: Text usually returned by dw_container_query(). 5994 * text: Text usually returned by dw_container_query().
5694 */ 5995 */
5695 void dw_container_cursor_by_data(HWND handle, void *data) 5996 DW_FUNCTION_DEFINITION(dw_container_cursor_by_data, void, HWND handle, void *data)
5696 { 5997 DW_FUNCTION_ADD_PARAM2(handle, data)
5697 _dw_container_cursor(handle, data, FALSE); 5998 DW_FUNCTION_NO_RETURN(dw_container_cursor_by_data)
5698 } 5999 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
5699 6000 {
5700 void _dw_container_delete_row(HWND handle, void *data, int textcomp) 6001 _dw_container_cursor_int(handle, data, FALSE);
6002 DW_FUNCTION_RETURN_NOTHING;
6003 }
6004
6005 void _dw_container_delete_row_int(HWND handle, void *data, int textcomp)
5701 { 6006 {
5702 GtkWidget *cont; 6007 GtkWidget *cont;
5703 GtkListStore *store = NULL; 6008 GtkListStore *store = NULL;
5704 6009
5705 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 6010 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5727 * Deletes the item with the text speficied. 6032 * Deletes the item with the text speficied.
5728 * Parameters: 6033 * Parameters:
5729 * handle: Handle to the window (widget). 6034 * handle: Handle to the window (widget).
5730 * text: Text usually returned by dw_container_query(). 6035 * text: Text usually returned by dw_container_query().
5731 */ 6036 */
5732 void dw_container_delete_row(HWND handle, const char *text) 6037 DW_FUNCTION_DEFINITION(dw_container_delete_row, void, HWND handle, const char *text)
5733 { 6038 DW_FUNCTION_ADD_PARAM2(handle, text)
5734 _dw_container_delete_row(handle, (void *)text, TRUE); 6039 DW_FUNCTION_NO_RETURN(dw_container_delete_row)
6040 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
6041 {
6042 _dw_container_delete_row_int(handle, (void *)text, TRUE);
6043 DW_FUNCTION_RETURN_NOTHING;
5735 } 6044 }
5736 6045
5737 /* 6046 /*
5738 * Deletes the item with the text speficied. 6047 * Deletes the item with the text speficied.
5739 * Parameters: 6048 * Parameters:
5740 * handle: Handle to the window (widget). 6049 * handle: Handle to the window (widget).
5741 * text: Text usually returned by dw_container_query(). 6050 * text: Text usually returned by dw_container_query().
5742 */ 6051 */
5743 void dw_container_delete_row_by_data(HWND handle, void *data) 6052 DW_FUNCTION_DEFINITION(dw_container_delete_row_by_data, void, HWND handle, void *data)
5744 { 6053 DW_FUNCTION_ADD_PARAM2(handle, data)
5745 _dw_container_delete_row(handle, data, FALSE); 6054 DW_FUNCTION_NO_RETURN(dw_container_delete_row_by_data)
6055 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, data, void *)
6056 {
6057 _dw_container_delete_row_int(handle, data, FALSE);
6058 DW_FUNCTION_RETURN_NOTHING;
5746 } 6059 }
5747 6060
5748 /* 6061 /*
5749 * Optimizes the column widths so that all data is visible. 6062 * Optimizes the column widths so that all data is visible.
5750 * Parameters: 6063 * Parameters:
5751 * handle: Handle to the window (widget) to be optimized. 6064 * handle: Handle to the window (widget) to be optimized.
5752 */ 6065 */
5753 void dw_container_optimize(HWND handle) 6066 DW_FUNCTION_DEFINITION(dw_container_optimize, void, HWND handle)
6067 DW_FUNCTION_ADD_PARAM1(handle)
6068 DW_FUNCTION_NO_RETURN(dw_container_optimize)
6069 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
5754 { 6070 {
5755 GtkWidget *cont; 6071 GtkWidget *cont;
5756 6072
5757 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user"); 6073 cont = (GtkWidget *)g_object_get_data(G_OBJECT(handle), "_dw_user");
5758 6074
5759 /* Make sure it is the correct tree type */ 6075 /* Make sure it is the correct tree type */
5760 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER)) 6076 if(cont && GTK_IS_TREE_VIEW(cont) && g_object_get_data(G_OBJECT(cont), "_dw_tree_type") == GINT_TO_POINTER(_DW_TREE_TYPE_CONTAINER))
5761 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(cont)); 6077 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(cont));
6078 DW_FUNCTION_RETURN_NOTHING;
5762 } 6079 }
5763 6080
5764 /* 6081 /*
5765 * Inserts an icon into the taskbar. 6082 * Inserts an icon into the taskbar.
5766 * Parameters: 6083 * Parameters:
5789 * Parameters: 6106 * Parameters:
5790 * id: An id to be used with dw_window_from_id. 6107 * id: An id to be used with dw_window_from_id.
5791 * Returns: 6108 * Returns:
5792 * A handle to the widget or NULL on failure. 6109 * A handle to the widget or NULL on failure.
5793 */ 6110 */
5794 HWND dw_render_new(unsigned long id) 6111 DW_FUNCTION_DEFINITION(dw_render_new, HWND, ULONG cid)
5795 { 6112 DW_FUNCTION_ADD_PARAM1(cid)
5796 GtkWidget *tmp; 6113 DW_FUNCTION_RETURN(dw_render_new, HWND)
5797 6114 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
5798 tmp = gtk_drawing_area_new(); 6115 {
5799 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 6116 GtkWidget *tmp = gtk_drawing_area_new();
6117 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
5800 gtk_widget_set_can_focus(tmp, TRUE); 6118 gtk_widget_set_can_focus(tmp, TRUE);
5801 gtk_widget_show(tmp); 6119 gtk_widget_show(tmp);
5802 if(_DWDefaultFont) 6120 if(_DWDefaultFont)
5803 dw_window_set_font(tmp, _DWDefaultFont); 6121 dw_window_set_font(tmp, _DWDefaultFont);
5804 return tmp; 6122 DW_FUNCTION_RETURN_THIS(tmp);
5805 } 6123 }
5806 6124
5807 /* Returns a GdkRGBA from a DW color */ 6125 /* Returns a GdkRGBA from a DW color */
5808 static GdkRGBA _internal_color(unsigned long value) 6126 static GdkRGBA _dw_internal_color(unsigned long value)
5809 { 6127 {
5810 if(DW_RGB_COLOR & value) 6128 if(DW_RGB_COLOR & value)
5811 { 6129 {
5812 GdkRGBA color = { (gfloat)DW_RED_VALUE(value) / 255.0, (gfloat)DW_GREEN_VALUE(value) / 255.0, (gfloat)DW_BLUE_VALUE(value) / 255.0, 1.0 }; 6130 GdkRGBA color = { (gfloat)DW_RED_VALUE(value) / 255.0, (gfloat)DW_GREEN_VALUE(value) / 255.0, (gfloat)DW_BLUE_VALUE(value) / 255.0, 1.0 };
5813 return color; 6131 return color;
5823 * green: green value. 6141 * green: green value.
5824 * blue: blue value. 6142 * blue: blue value.
5825 */ 6143 */
5826 void dw_color_foreground_set(unsigned long value) 6144 void dw_color_foreground_set(unsigned long value)
5827 { 6145 {
5828 GdkRGBA color = _internal_color(value); 6146 GdkRGBA color = _dw_internal_color(value);
5829 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key); 6147 GdkRGBA *foreground = pthread_getspecific(_dw_fg_color_key);
5830 6148
5831 *foreground = color; 6149 *foreground = color;
5832 } 6150 }
5833 6151
5849 free(background); 6167 free(background);
5850 } 6168 }
5851 } 6169 }
5852 else 6170 else
5853 { 6171 {
5854 GdkRGBA color = _internal_color(value); 6172 GdkRGBA color = _dw_internal_color(value);
5855 6173
5856 if(!background) 6174 if(!background)
5857 { 6175 {
5858 background = malloc(sizeof(GdkRGBA)); 6176 background = malloc(sizeof(GdkRGBA));
5859 pthread_setspecific(_dw_bg_color_key, background); 6177 pthread_setspecific(_dw_bg_color_key, background);
5866 * Parameters: 6184 * Parameters:
5867 * value: current color 6185 * value: current color
5868 * Returns: 6186 * Returns:
5869 * The selected color or the current color if cancelled. 6187 * The selected color or the current color if cancelled.
5870 */ 6188 */
5871 unsigned long API dw_color_choose(unsigned long value) 6189 DW_FUNCTION_DEFINITION(dw_color_choose, ULONG, ULONG value)
6190 DW_FUNCTION_ADD_PARAM1(value)
6191 DW_FUNCTION_RETURN(dw_color_choose, ULONG)
6192 DW_FUNCTION_RESTORE_PARAM1(value, ULONG)
5872 { 6193 {
5873 GtkColorChooser *cd; 6194 GtkColorChooser *cd;
5874 GdkRGBA color = _internal_color(value); 6195 GdkRGBA color = _dw_internal_color(value);
5875 unsigned long retcolor = value; 6196 unsigned long retcolor = value;
5876 DWDialog *tmp = dw_dialog_new(NULL); 6197 DWDialog *tmp = dw_dialog_new(NULL);
5877 6198
5878 cd = (GtkColorChooser *)gtk_color_chooser_dialog_new("Choose color", NULL); 6199 cd = (GtkColorChooser *)gtk_color_chooser_dialog_new("Choose color", NULL);
5879 gtk_color_chooser_set_use_alpha(cd, FALSE); 6200 gtk_color_chooser_set_use_alpha(cd, FALSE);
5887 gtk_color_chooser_get_rgba(cd, &color); 6208 gtk_color_chooser_get_rgba(cd, &color);
5888 retcolor = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255)); 6209 retcolor = DW_RGB((int)(color.red * 255), (int)(color.green * 255), (int)(color.blue * 255));
5889 } 6210 }
5890 if(GTK_IS_WINDOW(cd)) 6211 if(GTK_IS_WINDOW(cd))
5891 gtk_window_destroy(GTK_WINDOW(cd)); 6212 gtk_window_destroy(GTK_WINDOW(cd));
5892 return retcolor; 6213 DW_FUNCTION_RETURN_THIS(retcolor);
5893 } 6214 }
5894 6215
5895 /* Draw a point on a window (preferably a render window). 6216 /* Draw a point on a window (preferably a render window).
5896 * Parameters: 6217 * Parameters:
5897 * handle: Handle to the window. 6218 * handle: Handle to the window.
6330 * pixmap: Handle to the pixmap. (choose only one of these) 6651 * pixmap: Handle to the pixmap. (choose only one of these)
6331 * text: Text to be queried. 6652 * text: Text to be queried.
6332 * width: Pointer to a variable to be filled in with the width. 6653 * width: Pointer to a variable to be filled in with the width.
6333 * height Pointer to a variable to be filled in with the height. 6654 * height Pointer to a variable to be filled in with the height.
6334 */ 6655 */
6335 void dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height) 6656 DW_FUNCTION_DEFINITION(dw_font_text_extents_get, void, HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height)
6657 DW_FUNCTION_ADD_PARAM5(handle, pixmap, text, width, height)
6658 DW_FUNCTION_NO_RETURN(dw_font_text_extents_get)
6659 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, pixmap, HPIXMAP, text, const char *, width, int *, height, int *)
6336 { 6660 {
6337 PangoFontDescription *font; 6661 PangoFontDescription *font;
6338 char *fontname = NULL; 6662 char *fontname = NULL;
6339 int free_fontname = 0; 6663 int free_fontname = 0;
6340 6664
6341 if(!text) 6665 if(text)
6342 return; 6666 {
6343 6667 if(handle)
6344 if(handle) 6668 {
6345 { 6669 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname");
6346 fontname = (char *)g_object_get_data(G_OBJECT(handle), "_dw_fontname"); 6670 if ( fontname == NULL )
6347 if ( fontname == NULL )
6348 {
6349 fontname = dw_window_get_font(handle);
6350 free_fontname = 1;
6351 }
6352 }
6353 else if(pixmap)
6354 {
6355 if(pixmap->font)
6356 fontname = pixmap->font;
6357 else if(pixmap->handle)
6358 fontname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname");
6359 }
6360
6361 font = pango_font_description_from_string(fontname ? fontname : "monospace 10");
6362 if(font)
6363 {
6364 PangoContext *context = gtk_widget_get_pango_context(pixmap ? pixmap->handle : handle);
6365
6366 if(context)
6367 {
6368 PangoLayout *layout = pango_layout_new(context);
6369
6370 if(layout)
6371 { 6671 {
6372 PangoRectangle rect; 6672 fontname = dw_window_get_font(handle);
6373 6673 free_fontname = 1;
6374 pango_layout_set_font_description(layout, font);
6375 pango_layout_set_text(layout, text, -1);
6376 pango_layout_get_pixel_extents(layout, NULL, &rect);
6377
6378 if(width)
6379 *width = rect.width;
6380 if(height)
6381 *height = rect.height;
6382
6383 g_object_unref(layout);
6384 } 6674 }
6385 g_object_unref(context); 6675 }
6386 } 6676 else if(pixmap)
6387 pango_font_description_free(font); 6677 {
6388 } 6678 if(pixmap->font)
6389 if(free_fontname) 6679 fontname = pixmap->font;
6390 free(fontname); 6680 else if(pixmap->handle)
6681 fontname = (char *)g_object_get_data(G_OBJECT(pixmap->handle), "_dw_fontname");
6682 }
6683
6684 font = pango_font_description_from_string(fontname ? fontname : "monospace 10");
6685 if(font)
6686 {
6687 PangoContext *context = gtk_widget_get_pango_context(pixmap ? pixmap->handle : handle);
6688
6689 if(context)
6690 {
6691 PangoLayout *layout = pango_layout_new(context);
6692
6693 if(layout)
6694 {
6695 PangoRectangle rect;
6696
6697 pango_layout_set_font_description(layout, font);
6698 pango_layout_set_text(layout, text, -1);
6699 pango_layout_get_pixel_extents(layout, NULL, &rect);
6700
6701 if(width)
6702 *width = rect.width;
6703 if(height)
6704 *height = rect.height;
6705
6706 g_object_unref(layout);
6707 }
6708 g_object_unref(context);
6709 }
6710 pango_font_description_free(font);
6711 }
6712 if(free_fontname)
6713 free(fontname);
6714 }
6715 DW_FUNCTION_RETURN_NOTHING;
6391 } 6716 }
6392 6717
6393 /* 6718 /*
6394 * Creates a pixmap with given parameters. 6719 * Creates a pixmap with given parameters.
6395 * Parameters: 6720 * Parameters:
6631 * srcwidth: Width of area to copy. 6956 * srcwidth: Width of area to copy.
6632 * srcheight: Height of area to copy. 6957 * srcheight: Height of area to copy.
6633 * Returns: 6958 * Returns:
6634 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. 6959 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
6635 */ 6960 */
6636 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight) 6961 DW_FUNCTION_DEFINITION(dw_pixmap_stretch_bitblt, int, HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
6962 DW_FUNCTION_ADD_PARAM12(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, srcwidth, srcheight)
6963 DW_FUNCTION_RETURN(dw_pixmap_stretch_bitblt, int)
6964 DW_FUNCTION_RESTORE_PARAM12(dest, HWND, destp, HPIXMAP, xdest, int, ydest, int, width, int, height, int, src, HWND, srcp, HPIXMAP, xsrc, int, ysrc, int, srcwidth, int, srcheight, int)
6965
6637 { 6966 {
6638 cairo_t *cr = NULL; 6967 cairo_t *cr = NULL;
6639 int retval = DW_ERROR_GENERAL; 6968 int retval = DW_ERROR_GENERAL;
6640 GdkDrawContext *dc = NULL; 6969 GdkDrawContext *dc = NULL;
6641 int cached = FALSE; 6970 int cached = FALSE;
6642
6643 if((!dest && (!destp || !destp->image)) || (!src && (!srcp || !srcp->image)))
6644 return retval;
6645 6971
6646 if(dest) 6972 if(dest)
6647 { 6973 {
6648 if((cr = g_object_get_data(G_OBJECT(dest), "_dw_cr"))) 6974 if((cr = g_object_get_data(G_OBJECT(dest), "_dw_cr")))
6649 cached = TRUE; 6975 cached = TRUE;
6657 cairo_region_t *region = cairo_region_create(); 6983 cairo_region_t *region = cairo_region_create();
6658 gdk_draw_context_begin_frame(dc, region); 6984 gdk_draw_context_begin_frame(dc, region);
6659 cr = gdk_cairo_context_cairo_create(GDK_CAIRO_CONTEXT(dc)); 6985 cr = gdk_cairo_context_cairo_create(GDK_CAIRO_CONTEXT(dc));
6660 cairo_region_destroy(region); 6986 cairo_region_destroy(region);
6661 } 6987 }
6662 else
6663 return retval;
6664 } 6988 }
6665 } 6989 }
6666 else if(destp) 6990 else if(destp)
6667 cr = cairo_create(destp->image); 6991 cr = cairo_create(destp->image);
6668 6992
6694 gdk_draw_context_end_frame(dc); 7018 gdk_draw_context_end_frame(dc);
6695 else if(!cached) 7019 else if(!cached)
6696 cairo_destroy(cr); 7020 cairo_destroy(cr);
6697 retval = DW_ERROR_NONE; 7021 retval = DW_ERROR_NONE;
6698 } 7022 }
6699 return retval; 7023 DW_FUNCTION_RETURN_THIS(retval);
6700 } 7024 }
6701 7025
6702 /* 7026 /*
6703 * Emits a beep. 7027 * Emits a beep.
6704 * Parameters: 7028 * Parameters:
7910 * height: Height in pixels of the item or -1 to be self determined. 8234 * height: Height in pixels of the item or -1 to be self determined.
7911 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. 8235 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
7912 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 8236 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
7913 * pad: Number of pixels of padding around the item. 8237 * pad: Number of pixels of padding around the item.
7914 */ 8238 */
7915 void API dw_box_pack_at_index(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad) 8239 DW_FUNCTION_DEFINITION(dw_box_pack_at_index, void, HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
8240 DW_FUNCTION_ADD_PARAM8(box, item, index, width, height, hsize, vsize, pad)
8241 DW_FUNCTION_NO_RETURN(dw_box_pack_at_index)
8242 DW_FUNCTION_RESTORE_PARAM8(box, HWND, item, HWND, index, int, width, int, height, int, hsize, int, vsize, int, pad, int)
7916 { 8243 {
7917 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()"); 8244 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
8245 DW_FUNCTION_RETURN_NOTHING;
7918 } 8246 }
7919 8247
7920 /* 8248 /*
7921 * Pack windows (widgets) into a box from the start (or top). 8249 * Pack windows (widgets) into a box from the start (or top).
7922 * Parameters: 8250 * Parameters:
7926 * height: Height in pixels of the item or -1 to be self determined. 8254 * height: Height in pixels of the item or -1 to be self determined.
7927 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. 8255 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
7928 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 8256 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
7929 * pad: Number of pixels of padding around the item. 8257 * pad: Number of pixels of padding around the item.
7930 */ 8258 */
7931 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 8259 DW_FUNCTION_DEFINITION(dw_box_pack_start, void, HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
8260 DW_FUNCTION_ADD_PARAM7(box, item, width, height, hsize, vsize, pad)
8261 DW_FUNCTION_NO_RETURN(dw_box_pack_start)
8262 DW_FUNCTION_RESTORE_PARAM7(box, HWND, item, HWND, width, int, height, int, hsize, int, vsize, int, pad, int)
7932 { 8263 {
7933 /* 65536 is the table limit on GTK... 8264 /* 65536 is the table limit on GTK...
7934 * seems like a high enough value we will never hit it here either. 8265 * seems like a high enough value we will never hit it here either.
7935 */ 8266 */
7936 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()"); 8267 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()");
8268 DW_FUNCTION_RETURN_NOTHING;
7937 } 8269 }
7938 8270
7939 /* 8271 /*
7940 * Pack windows (widgets) into a box from the end (or bottom). 8272 * Pack windows (widgets) into a box from the end (or bottom).
7941 * Parameters: 8273 * Parameters:
7945 * height: Height in pixels of the item or -1 to be self determined. 8277 * height: Height in pixels of the item or -1 to be self determined.
7946 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. 8278 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
7947 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 8279 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
7948 * pad: Number of pixels of padding around the item. 8280 * pad: Number of pixels of padding around the item.
7949 */ 8281 */
7950 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 8282 DW_FUNCTION_DEFINITION(dw_box_pack_end, void, HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
8283 DW_FUNCTION_ADD_PARAM7(box, item, width, height, hsize, vsize, pad)
8284 DW_FUNCTION_NO_RETURN(dw_box_pack_end)
8285 DW_FUNCTION_RESTORE_PARAM7(box, HWND, item, HWND, width, int, height, int, hsize, int, vsize, int, pad, int)
7951 { 8286 {
7952 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()"); 8287 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
8288 DW_FUNCTION_RETURN_NOTHING;
7953 } 8289 }
7954 8290
7955 /* 8291 /*
7956 * Sets the size of a given window (widget). 8292 * Sets the size of a given window (widget).
7957 * Parameters: 8293 * Parameters:
7979 * Parameters: 8315 * Parameters:
7980 * handle: Window handle of the item to be back. 8316 * handle: Window handle of the item to be back.
7981 * width: Width in pixels of the item or NULL if not needed. 8317 * width: Width in pixels of the item or NULL if not needed.
7982 * height: Height in pixels of the item or NULL if not needed. 8318 * height: Height in pixels of the item or NULL if not needed.
7983 */ 8319 */
7984 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) 8320 DW_FUNCTION_DEFINITION(dw_window_get_preferred_size, void, HWND handle, int *width, int *height)
8321 DW_FUNCTION_ADD_PARAM3(handle, width, height)
8322 DW_FUNCTION_NO_RETURN(dw_window_get_preferred_size)
8323 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, width, int *, height, int *)
7985 { 8324 {
7986 if(GTK_IS_SCROLLED_WINDOW(handle)) 8325 if(GTK_IS_SCROLLED_WINDOW(handle))
7987 { 8326 {
7988 gint scrolledwidth, scrolledheight; 8327 gint scrolledwidth, scrolledheight;
7989 8328
7999 if(width) 8338 if(width)
8000 gtk_widget_measure(GTK_WIDGET(handle), GTK_ORIENTATION_HORIZONTAL, -1, width, NULL, NULL, NULL); 8339 gtk_widget_measure(GTK_WIDGET(handle), GTK_ORIENTATION_HORIZONTAL, -1, width, NULL, NULL, NULL);
8001 if(height) 8340 if(height)
8002 gtk_widget_measure(GTK_WIDGET(handle), GTK_ORIENTATION_VERTICAL, -1, height, NULL, NULL, NULL); 8341 gtk_widget_measure(GTK_WIDGET(handle), GTK_ORIENTATION_VERTICAL, -1, height, NULL, NULL, NULL);
8003 } 8342 }
8343 DW_FUNCTION_RETURN_NOTHING;
8004 } 8344 }
8005 8345
8006 /* Internal version to simplify the code with multiple versions of GTK */ 8346 /* Internal version to simplify the code with multiple versions of GTK */
8007 int _dw_screen_width(void) 8347 int _dw_screen_width(void)
8008 { 8348 {
8116 * x: X location from the bottom left. 8456 * x: X location from the bottom left.
8117 * y: Y location from the bottom left. 8457 * y: Y location from the bottom left.
8118 * width: Width of the widget. 8458 * width: Width of the widget.
8119 * height: Height of the widget. 8459 * height: Height of the widget.
8120 */ 8460 */
8121 void dw_window_get_pos_size(HWND handle, long *x, long *y, ULONG *width, ULONG *height) 8461 DW_FUNCTION_DEFINITION(dw_window_get_pos_size, void, HWND handle, long *x, long *y, ULONG *width, ULONG *height)
8462 DW_FUNCTION_ADD_PARAM5(handle, x, y, width, height)
8463 DW_FUNCTION_NO_RETURN(dw_window_get_pos_size)
8464 DW_FUNCTION_RESTORE_PARAM5(handle, HWND, x, long *, y, long *, width, ULONG *, height, ULONG *)
8122 { 8465 {
8123 /* TODO: Figure out how to do this in GTK4 with no GdkWindow */ 8466 /* TODO: Figure out how to do this in GTK4 with no GdkWindow */
8124 if(!handle || !GTK_IS_WIDGET(handle)) 8467 if(handle && GTK_IS_WIDGET(handle))
8125 return; 8468 {
8126 8469 if(width)
8127 if(width) 8470 *width = (ULONG)gtk_widget_get_width(GTK_WIDGET(handle));
8128 *width = (ULONG)gtk_widget_get_width(GTK_WIDGET(handle)); 8471 if(height)
8129 if(height) 8472 *height = (ULONG)gtk_widget_get_height(GTK_WIDGET(handle));
8130 *height = (ULONG)gtk_widget_get_height(GTK_WIDGET(handle)); 8473 if(x)
8131 if(x) 8474 *x = 0;
8132 *x = 0; 8475 if(y)
8133 if(y) 8476 *y = 0;
8134 *y = 0; 8477 }
8478 DW_FUNCTION_RETURN_NOTHING;
8135 } 8479 }
8136 8480
8137 /* 8481 /*
8138 * Sets the style of a given window (widget). 8482 * Sets the style of a given window (widget).
8139 * Parameters: 8483 * Parameters:
8140 * handle: Window (widget) handle. 8484 * handle: Window (widget) handle.
8141 * width: New width in pixels. 8485 * width: New width in pixels.
8142 * height: New height in pixels. 8486 * height: New height in pixels.
8143 */ 8487 */
8144 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask) 8488 DW_FUNCTION_DEFINITION(dw_window_set_style, void, HWND handle, ULONG style, ULONG mask)
8489 DW_FUNCTION_ADD_PARAM3(handle, style, mask)
8490 DW_FUNCTION_NO_RETURN(dw_window_set_style)
8491 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, style, ULONG, mask, ULONG)
8145 { 8492 {
8146 GtkWidget *handle2 = handle; 8493 GtkWidget *handle2 = handle;
8147 8494
8148 if(GTK_IS_SCROLLED_WINDOW(handle)) 8495 if(GTK_IS_SCROLLED_WINDOW(handle))
8149 { 8496 {
8215 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(handle2)) != check) 8562 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(handle2)) != check)
8216 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(handle2), check); 8563 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(handle2), check);
8217 _dw_ignore_click = 0; 8564 _dw_ignore_click = 0;
8218 } 8565 }
8219 #endif 8566 #endif
8567 DW_FUNCTION_RETURN_NOTHING;
8220 } 8568 }
8221 8569
8222 /* 8570 /*
8223 * Adds a new page to specified notebook. 8571 * Adds a new page to specified notebook.
8224 * Parameters: 8572 * Parameters:
8225 * handle: Window (widget) handle. 8573 * handle: Window (widget) handle.
8226 * flags: Any additional page creation flags. 8574 * flags: Any additional page creation flags.
8227 * front: If TRUE page is added at the beginning. 8575 * front: If TRUE page is added at the beginning.
8228 */ 8576 */
8229 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front) 8577 DW_FUNCTION_DEFINITION(dw_notebook_page_new, ULONG, HWND handle, DW_UNUSED(ULONG flags), int front)
8230 { 8578 DW_FUNCTION_ADD_PARAM3(handle, flags, front)
8579 DW_FUNCTION_RETURN(dw_notebook_page_new, ULONG)
8580 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, DW_UNUSED(flags), ULONG, front, int)
8581 {
8582 GtkWidget **pagearray;
8583 ULONG retval = 256;
8231 int z; 8584 int z;
8232 GtkWidget **pagearray;
8233 8585
8234 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray"); 8586 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
8235 8587
8236 if(pagearray) 8588 if(pagearray)
8237 { 8589 {
8246 num |= 1 << 16; 8598 num |= 1 << 16;
8247 8599
8248 snprintf(text, 100, "_dw_page%d", z); 8600 snprintf(text, 100, "_dw_page%d", z);
8249 /* Save the real id and the creation flags */ 8601 /* Save the real id and the creation flags */
8250 g_object_set_data(G_OBJECT(handle), text, GINT_TO_POINTER(num)); 8602 g_object_set_data(G_OBJECT(handle), text, GINT_TO_POINTER(num));
8251 return z; 8603 retval = (ULONG)z;
8604 z = 256;
8252 } 8605 }
8253 } 8606 }
8254 } 8607 }
8255 8608 DW_FUNCTION_RETURN_THIS(retval);
8256 /* Hopefully this won't happen. */
8257 return 256;
8258 } 8609 }
8259 8610
8260 /* Return the physical page id from the logical page id */ 8611 /* Return the physical page id from the logical page id */
8261 int _get_physical_page(HWND handle, unsigned long pageid) 8612 int _get_physical_page(HWND handle, unsigned long pageid)
8262 { 8613 {
8281 * Remove a page from a notebook. 8632 * Remove a page from a notebook.
8282 * Parameters: 8633 * Parameters:
8283 * handle: Handle to the notebook widget. 8634 * handle: Handle to the notebook widget.
8284 * pageid: ID of the page to be destroyed. 8635 * pageid: ID of the page to be destroyed.
8285 */ 8636 */
8286 void dw_notebook_page_destroy(HWND handle, unsigned int pageid) 8637 DW_FUNCTION_DEFINITION(dw_notebook_page_destroy, void, HWND handle, unsigned int pageid)
8638 DW_FUNCTION_ADD_PARAM2(handle, pageid)
8639 DW_FUNCTION_NO_RETURN(dw_notebook_page_destroy)
8640 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pageid, unsigned int)
8287 { 8641 {
8288 int realpage; 8642 int realpage;
8289 GtkWidget **pagearray; 8643 GtkWidget **pagearray;
8290 8644
8291 realpage = _get_physical_page(handle, pageid); 8645 realpage = _get_physical_page(handle, pageid);
8293 { 8647 {
8294 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage); 8648 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage);
8295 if((pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray"))) 8649 if((pagearray = g_object_get_data(G_OBJECT(handle), "_dw_pagearray")))
8296 pagearray[pageid] = NULL; 8650 pagearray[pageid] = NULL;
8297 } 8651 }
8652 DW_FUNCTION_RETURN_NOTHING;
8298 } 8653 }
8299 8654
8300 /* 8655 /*
8301 * Queries the currently visible page ID. 8656 * Queries the currently visible page ID.
8302 * Parameters: 8657 * Parameters:
8303 * handle: Handle to the notebook widget. 8658 * handle: Handle to the notebook widget.
8304 */ 8659 */
8305 unsigned long dw_notebook_page_get(HWND handle) 8660 DW_FUNCTION_DEFINITION(dw_notebook_page_get, ULONG, HWND handle)
8306 { 8661 DW_FUNCTION_ADD_PARAM1(handle)
8307 int retval, phys; 8662 DW_FUNCTION_RETURN(dw_notebook_page_get, ULONG)
8663 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
8664 {
8665 int phys;
8666 ULONG retval;
8308 8667
8309 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle)); 8668 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle));
8310 retval = _dw_get_logical_page(handle, phys); 8669 retval = _dw_get_logical_page(handle, phys);
8311 return retval; 8670 DW_FUNCTION_RETURN_THIS(retval);
8312 } 8671 }
8313 8672
8314 /* 8673 /*
8315 * Sets the currently visibale page ID. 8674 * Sets the currently visibale page ID.
8316 * Parameters: 8675 * Parameters:
8317 * handle: Handle to the notebook widget. 8676 * handle: Handle to the notebook widget.
8318 * pageid: ID of the page to be made visible. 8677 * pageid: ID of the page to be made visible.
8319 */ 8678 */
8320 void dw_notebook_page_set(HWND handle, unsigned int pageid) 8679 DW_FUNCTION_DEFINITION(dw_notebook_page_set, void, HWND handle, unsigned int pageid)
8680 DW_FUNCTION_ADD_PARAM2(handle, pageid)
8681 DW_FUNCTION_NO_RETURN(dw_notebook_page_set)
8682 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, pageid, unsigned int)
8321 { 8683 {
8322 int realpage; 8684 int realpage;
8323 8685
8324 realpage = _get_physical_page(handle, pageid); 8686 realpage = _get_physical_page(handle, pageid);
8325 if(realpage > -1 && realpage < 256) 8687 if(realpage > -1 && realpage < 256)
8326 gtk_notebook_set_current_page(GTK_NOTEBOOK(handle), pageid); 8688 gtk_notebook_set_current_page(GTK_NOTEBOOK(handle), pageid);
8689 DW_FUNCTION_RETURN_NOTHING;
8327 } 8690 }
8328 8691
8329 8692
8330 /* 8693 /*
8331 * Sets the text on the specified notebook tab. 8694 * Sets the text on the specified notebook tab.
8332 * Parameters: 8695 * Parameters:
8333 * handle: Notebook handle. 8696 * handle: Notebook handle.
8334 * pageid: Page ID of the tab to set. 8697 * pageid: Page ID of the tab to set.
8335 * text: Pointer to the text to set. 8698 * text: Pointer to the text to set.
8336 */ 8699 */
8337 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, const char *text) 8700 DW_FUNCTION_DEFINITION(dw_notebook_page_set_text, void, HWND handle, ULONG pageid, const char *text)
8701 DW_FUNCTION_ADD_PARAM3(handle, pageid, text)
8702 DW_FUNCTION_NO_RETURN(dw_notebook_page_set_text)
8703 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pageid, ULONG, text, const char *)
8338 { 8704 {
8339 GtkWidget *child; 8705 GtkWidget *child;
8340 int realpage; 8706 int realpage;
8341 8707
8342 realpage = _get_physical_page(handle, pageid); 8708 realpage = _get_physical_page(handle, pageid);
8354 { 8720 {
8355 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage); 8721 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage);
8356 if(child) 8722 if(child)
8357 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text); 8723 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text);
8358 } 8724 }
8725 DW_FUNCTION_RETURN_NOTHING;
8359 } 8726 }
8360 8727
8361 /* 8728 /*
8362 * Sets the text on the specified notebook tab status area. 8729 * Sets the text on the specified notebook tab status area.
8363 * Parameters: 8730 * Parameters:
8375 * Parameters: 8742 * Parameters:
8376 * handle: Handle to the notebook to be packed. 8743 * handle: Handle to the notebook to be packed.
8377 * pageid: Page ID in the notebook which is being packed. 8744 * pageid: Page ID in the notebook which is being packed.
8378 * page: Box handle to be packed. 8745 * page: Box handle to be packed.
8379 */ 8746 */
8380 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page) 8747 DW_FUNCTION_DEFINITION(dw_notebook_pack, void, HWND handle, ULONG pageid, HWND page)
8748 DW_FUNCTION_ADD_PARAM3(handle, pageid, page)
8749 DW_FUNCTION_NO_RETURN(dw_notebook_pack)
8750 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, pageid, ULONG, page, HWND)
8381 { 8751 {
8382 GtkWidget *label, *child, *oldlabel, **pagearray; 8752 GtkWidget *label, *child, *oldlabel, **pagearray;
8383 const gchar *text = NULL; 8753 const gchar *text = NULL;
8384 int num, z, realpage = -1; 8754 int num, z, realpage = -1;
8385 char ptext[101] = {0}; 8755 char ptext[101] = {0};
8387 snprintf(ptext, 100, "_dw_page%d", (int)pageid); 8757 snprintf(ptext, 100, "_dw_page%d", (int)pageid);
8388 num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), ptext)); 8758 num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(handle), ptext));
8389 g_object_set_data(G_OBJECT(handle), ptext, NULL); 8759 g_object_set_data(G_OBJECT(handle), ptext, NULL);
8390 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray"); 8760 pagearray = (GtkWidget **)g_object_get_data(G_OBJECT(handle), "_dw_pagearray");
8391 8761
8392 if(!pagearray) 8762 if(pagearray)
8393 return; 8763 {
8394 8764 /* The page already exists... so get it's current page */
8395 /* The page already exists... so get it's current page */ 8765 if(pagearray[pageid])
8396 if(pagearray[pageid]) 8766 {
8397 { 8767 for(z=0;z<256;z++)
8398 for(z=0;z<256;z++)
8399 {
8400 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z);
8401 if(child == pagearray[pageid])
8402 { 8768 {
8403 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child); 8769 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z);
8404 if(oldlabel) 8770 if(child == pagearray[pageid])
8405 text = gtk_label_get_text(GTK_LABEL(oldlabel)); 8771 {
8406 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), z); 8772 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child);
8407 realpage = z; 8773 if(oldlabel)
8408 break; 8774 text = gtk_label_get_text(GTK_LABEL(oldlabel));
8775 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), z);
8776 realpage = z;
8777 break;
8778 }
8409 } 8779 }
8410 } 8780 }
8411 } 8781
8412 8782 pagearray[pageid] = page;
8413 pagearray[pageid] = page; 8783
8414 8784 label = gtk_label_new(text ? text : "");
8415 label = gtk_label_new(text ? text : ""); 8785
8416 8786 if(realpage != -1)
8417 if(realpage != -1) 8787 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, realpage);
8418 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, realpage); 8788 else if(num & ~(0xFF))
8419 else if(num & ~(0xFF)) 8789 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 0);
8420 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 0); 8790 else
8421 else 8791 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
8422 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256); 8792 }
8793 DW_FUNCTION_RETURN_NOTHING;
8423 } 8794 }
8424 8795
8425 /* 8796 /*
8426 * Appends the specified text to the listbox's (or combobox) entry list. 8797 * Appends the specified text to the listbox's (or combobox) entry list.
8427 * Parameters: 8798 * Parameters:
8571 /* 8942 /*
8572 * Returns the listbox's item count. 8943 * Returns the listbox's item count.
8573 * Parameters: 8944 * Parameters:
8574 * handle: Handle to the listbox to be counted 8945 * handle: Handle to the listbox to be counted
8575 */ 8946 */
8576 int dw_listbox_count(HWND handle) 8947 DW_FUNCTION_DEFINITION(dw_listbox_count, int, HWND handle)
8948 DW_FUNCTION_ADD_PARAM1(handle)
8949 DW_FUNCTION_RETURN(dw_listbox_count, int)
8950 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
8577 { 8951 {
8578 GtkWidget *handle2 = handle; 8952 GtkWidget *handle2 = handle;
8579 GtkListStore *store = NULL; 8953 GtkListStore *store = NULL;
8580 int retval = 0; 8954 int retval = 0;
8581 8955
8598 { 8972 {
8599 /* Get the number of children at the top level */ 8973 /* Get the number of children at the top level */
8600 retval = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); 8974 retval = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
8601 } 8975 }
8602 } 8976 }
8603 return retval; 8977 DW_FUNCTION_RETURN_THIS(retval);
8604 } 8978 }
8605 8979
8606 /* 8980 /*
8607 * Sets the topmost item in the viewport. 8981 * Sets the topmost item in the viewport.
8608 * Parameters: 8982 * Parameters:
9031 * topleft: Handle to the window to be top or left. 9405 * topleft: Handle to the window to be top or left.
9032 * bottomright: Handle to the window to be bottom or right. 9406 * bottomright: Handle to the window to be bottom or right.
9033 * Returns: 9407 * Returns:
9034 * A handle to a splitbar window or NULL on failure. 9408 * A handle to a splitbar window or NULL on failure.
9035 */ 9409 */
9036 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) 9410 DW_FUNCTION_DEFINITION(dw_splitbar_new, HWND, int type, HWND topleft, HWND bottomright, unsigned long cid)
9411 DW_FUNCTION_ADD_PARAM4(type, topleft, bottomright, cid)
9412 DW_FUNCTION_RETURN(dw_splitbar_new, HWND)
9413 DW_FUNCTION_RESTORE_PARAM4(type, int, topleft, HWND, bottomright, HWND, cid, unsigned long)
9037 { 9414 {
9038 GtkWidget *tmp = NULL; 9415 GtkWidget *tmp = NULL;
9039 float *percent = malloc(sizeof(float)); 9416 float *percent = malloc(sizeof(float));
9040 9417
9041 tmp = gtk_paned_new(type == DW_HORZ ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL); 9418 tmp = gtk_paned_new(type == DW_HORZ ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
9043 gtk_paned_set_resize_start_child(GTK_PANED(tmp), TRUE); 9420 gtk_paned_set_resize_start_child(GTK_PANED(tmp), TRUE);
9044 gtk_paned_set_shrink_start_child(GTK_PANED(tmp), FALSE); 9421 gtk_paned_set_shrink_start_child(GTK_PANED(tmp), FALSE);
9045 gtk_paned_set_end_child(GTK_PANED(tmp), bottomright); 9422 gtk_paned_set_end_child(GTK_PANED(tmp), bottomright);
9046 gtk_paned_set_resize_end_child(GTK_PANED(tmp), TRUE); 9423 gtk_paned_set_resize_end_child(GTK_PANED(tmp), TRUE);
9047 gtk_paned_set_shrink_end_child(GTK_PANED(tmp), FALSE); 9424 gtk_paned_set_shrink_end_child(GTK_PANED(tmp), FALSE);
9048 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 9425 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
9049 *percent = 50.0; 9426 *percent = 50.0;
9050 g_object_set_data(G_OBJECT(tmp), "_dw_percent", (gpointer)percent); 9427 g_object_set_data(G_OBJECT(tmp), "_dw_percent", (gpointer)percent);
9051 g_signal_connect(G_OBJECT(tmp), "realize", G_CALLBACK(_dw_splitbar_realize), NULL); 9428 g_signal_connect(G_OBJECT(tmp), "realize", G_CALLBACK(_dw_splitbar_realize), NULL);
9052 gtk_widget_show(tmp); 9429 gtk_widget_show(tmp);
9053 return tmp; 9430 DW_FUNCTION_RETURN_THIS(tmp);
9054 } 9431 }
9055 9432
9056 /* 9433 /*
9057 * Sets the position of a splitbar (pecentage). 9434 * Sets the position of a splitbar (pecentage).
9058 * Parameters: 9435 * Parameters:
9059 * handle: The handle to the splitbar returned by dw_splitbar_new(). 9436 * handle: The handle to the splitbar returned by dw_splitbar_new().
9060 */ 9437 */
9061 void dw_splitbar_set(HWND handle, float percent) 9438 DW_FUNCTION_DEFINITION(dw_splitbar_set, void, HWND handle, float percent)
9439 DW_FUNCTION_ADD_PARAM2(handle, percent)
9440 DW_FUNCTION_NO_RETURN(dw_splitbar_set)
9441 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, percent, float)
9062 { 9442 {
9063 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent"); 9443 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
9064 int size = 0, position; 9444 int size = 0, position;
9065 9445
9066 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_HORIZONTAL) 9446 if(gtk_orientable_get_orientation(GTK_ORIENTABLE(handle)) == GTK_ORIENTATION_HORIZONTAL)
9075 { 9455 {
9076 position = (int)((float)size * (percent / 100.0)); 9456 position = (int)((float)size * (percent / 100.0));
9077 9457
9078 gtk_paned_set_position(GTK_PANED(handle), position); 9458 gtk_paned_set_position(GTK_PANED(handle), position);
9079 } 9459 }
9460 DW_FUNCTION_RETURN_NOTHING;
9080 } 9461 }
9081 9462
9082 /* 9463 /*
9083 * Gets the position of a splitbar (pecentage). 9464 * Gets the position of a splitbar (pecentage).
9084 * Parameters: 9465 * Parameters:
9085 * handle: The handle to the splitbar returned by dw_splitbar_new(). 9466 * handle: The handle to the splitbar returned by dw_splitbar_new().
9086 */ 9467 */
9087 float dw_splitbar_get(HWND handle) 9468 DW_FUNCTION_DEFINITION(dw_splitbar_get, float, HWND handle)
9469 DW_FUNCTION_ADD_PARAM1(handle)
9470 DW_FUNCTION_RETURN(dw_splitbar_get, float)
9471 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
9088 { 9472 {
9089 float *percent = (float *)dw_window_get_data(handle, "_dw_percent"); 9473 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
9474 float retval = 0.0;
9090 9475
9091 if(percent) 9476 if(percent)
9092 return *percent; 9477 retval = *percent;
9093 return 0.0; 9478 DW_FUNCTION_RETURN_THIS(retval);
9094 } 9479 }
9095 9480
9096 /* 9481 /*
9097 * Creates a calendar window (widget) with given parameters. 9482 * Creates a calendar window (widget) with given parameters.
9098 * Parameters: 9483 * Parameters:
9099 * id: Unique identifier for calendar widget 9484 * id: Unique identifier for calendar widget
9100 * Returns: 9485 * Returns:
9101 * A handle to a calendar window or NULL on failure. 9486 * A handle to a calendar window or NULL on failure.
9102 */ 9487 */
9103 HWND dw_calendar_new(unsigned long id) 9488 DW_FUNCTION_DEFINITION(dw_calendar_new, HWND, ULONG cid)
9489 DW_FUNCTION_ADD_PARAM1(cid)
9490 DW_FUNCTION_RETURN(dw_calendar_new, HWND)
9491 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG)
9104 { 9492 {
9105 GtkWidget *tmp = gtk_calendar_new(); 9493 GtkWidget *tmp = gtk_calendar_new();
9106 GTimeZone *tz = g_time_zone_new_local(); 9494 GTimeZone *tz = g_time_zone_new_local();
9107 GDateTime *now = g_date_time_new_now(tz); 9495 GDateTime *now = g_date_time_new_now(tz);
9108 9496
9109 gtk_widget_show(tmp); 9497 gtk_widget_show(tmp);
9110 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); 9498 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(cid));
9111 /* select today */ 9499 /* select today */
9112 gtk_calendar_set_show_day_names(GTK_CALENDAR(tmp), TRUE); 9500 gtk_calendar_set_show_day_names(GTK_CALENDAR(tmp), TRUE);
9113 gtk_calendar_set_show_heading(GTK_CALENDAR(tmp), TRUE); 9501 gtk_calendar_set_show_heading(GTK_CALENDAR(tmp), TRUE);
9114 gtk_calendar_select_day(GTK_CALENDAR(tmp), now); 9502 gtk_calendar_select_day(GTK_CALENDAR(tmp), now);
9115 g_date_time_unref(now); 9503 g_date_time_unref(now);
9116 g_time_zone_unref(tz); 9504 g_time_zone_unref(tz);
9117 return tmp; 9505 DW_FUNCTION_RETURN_THIS(tmp);
9118 } 9506 }
9119 9507
9120 /* 9508 /*
9121 * Sets the current date of a calendar 9509 * Sets the current date of a calendar
9122 * Parameters: 9510 * Parameters:
9123 * handle: The handle to the calendar returned by dw_calendar_new(). 9511 * handle: The handle to the calendar returned by dw_calendar_new().
9124 * year... 9512 * year...
9125 */ 9513 */
9126 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day) 9514 DW_FUNCTION_DEFINITION(dw_calendar_set_date, void, HWND handle, unsigned int year, unsigned int month, unsigned int day)
9515 DW_FUNCTION_ADD_PARAM4(handle, year, month, day)
9516 DW_FUNCTION_NO_RETURN(dw_calendar_set_date)
9517 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, year, unsigned int, month, unsigned int, day, unsigned int)
9127 { 9518 {
9128 if(GTK_IS_CALENDAR(handle)) 9519 if(GTK_IS_CALENDAR(handle))
9129 { 9520 {
9130 GTimeZone *tz = g_time_zone_new_local(); 9521 GTimeZone *tz = g_time_zone_new_local();
9131 GDateTime *datetime = g_date_time_new(tz, year, month, day, 0, 0, 0); 9522 GDateTime *datetime = g_date_time_new(tz, year, month, day, 0, 0, 0);
9132 gtk_calendar_select_day(GTK_CALENDAR(handle), datetime); 9523 gtk_calendar_select_day(GTK_CALENDAR(handle), datetime);
9133 g_date_time_unref(datetime); 9524 g_date_time_unref(datetime);
9134 g_time_zone_unref(tz); 9525 g_time_zone_unref(tz);
9135 } 9526 }
9527 DW_FUNCTION_RETURN_NOTHING;
9136 } 9528 }
9137 9529
9138 /* 9530 /*
9139 * Gets the position of a splitbar (pecentage). 9531 * Gets the position of a splitbar (pecentage).
9140 * Parameters: 9532 * Parameters:
9141 * handle: The handle to the splitbar returned by dw_splitbar_new(). 9533 * handle: The handle to the splitbar returned by dw_splitbar_new().
9142 */ 9534 */
9143 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day) 9535 DW_FUNCTION_DEFINITION(dw_calendar_get_date, void, HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
9536 DW_FUNCTION_ADD_PARAM4(handle, year, month, day)
9537 DW_FUNCTION_NO_RETURN(dw_calendar_get_date)
9538 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, year, unsigned int *, month, unsigned int *, day, unsigned int *)
9144 { 9539 {
9145 if(GTK_IS_CALENDAR(handle)) 9540 if(GTK_IS_CALENDAR(handle))
9146 { 9541 {
9147 GDateTime *datetime = gtk_calendar_get_date(GTK_CALENDAR(handle)); 9542 GDateTime *datetime = gtk_calendar_get_date(GTK_CALENDAR(handle));
9148 if(year) 9543 if(year)
9150 if(month) 9545 if(month)
9151 *month = g_date_time_get_month(datetime); 9546 *month = g_date_time_get_month(datetime);
9152 if(day) 9547 if(day)
9153 *day = g_date_time_get_day_of_month(datetime); 9548 *day = g_date_time_get_day_of_month(datetime);
9154 } 9549 }
9550 DW_FUNCTION_RETURN_NOTHING;
9155 } 9551 }
9156 9552
9157 /* 9553 /*
9158 * Sets the current focus item for a window/dialog. 9554 * Sets the current focus item for a window/dialog.
9159 * Parameters: 9555 * Parameters:
9160 * handle: Handle to the dialog item to be focused. 9556 * handle: Handle to the dialog item to be focused.
9161 * Remarks: 9557 * Remarks:
9162 * This is for use after showing the window/dialog. 9558 * This is for use after showing the window/dialog.
9163 */ 9559 */
9164 void API dw_window_set_focus(HWND handle) 9560 DW_FUNCTION_DEFINITION(dw_window_set_focus, void, HWND handle)
9165 { 9561 DW_FUNCTION_ADD_PARAM1(handle)
9166 if(!handle) 9562 DW_FUNCTION_NO_RETURN(dw_window_set_focus)
9167 return; 9563 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
9168 9564 {
9169 gtk_widget_grab_focus(handle); 9565 if(handle)
9566 gtk_widget_grab_focus(handle);
9567 DW_FUNCTION_RETURN_NOTHING;
9170 } 9568 }
9171 9569
9172 /* 9570 /*
9173 * Sets the default focus item for a window/dialog. 9571 * Sets the default focus item for a window/dialog.
9174 * Parameters: 9572 * Parameters:
9177 * Remarks: 9575 * Remarks:
9178 * This is for use before showing the window/dialog. 9576 * This is for use before showing the window/dialog.
9179 */ 9577 */
9180 void dw_window_default(HWND window, HWND defaultitem) 9578 void dw_window_default(HWND window, HWND defaultitem)
9181 { 9579 {
9182 if(!window) 9580 if(window)
9183 return; 9581 g_object_set_data(G_OBJECT(window), "_dw_defaultitem", (gpointer)defaultitem);
9184
9185 g_object_set_data(G_OBJECT(window), "_dw_defaultitem", (gpointer)defaultitem);
9186 } 9582 }
9187 9583
9188 /* 9584 /*
9189 * Sets window to click the default dialog item when an ENTER is pressed. 9585 * Sets window to click the default dialog item when an ENTER is pressed.
9190 * Parameters: 9586 * Parameters:
9191 * window: Window (widget) to look for the ENTER press. 9587 * window: Window (widget) to look for the ENTER press.
9192 * next: Window (widget) to move to next (or click) 9588 * next: Window (widget) to move to next (or click)
9193 */ 9589 */
9194 void dw_window_click_default(HWND window, HWND next) 9590 DW_FUNCTION_DEFINITION(dw_window_click_default, void, HWND window, HWND next)
9591 DW_FUNCTION_ADD_PARAM2(window, next)
9592 DW_FUNCTION_NO_RETURN(dw_window_click_default)
9593 DW_FUNCTION_RESTORE_PARAM2(window, HWND, next, HWND)
9195 { 9594 {
9196 if(window && next && GTK_IS_WIDGET(window) && GTK_IS_WIDGET(next)) 9595 if(window && next && GTK_IS_WIDGET(window) && GTK_IS_WIDGET(next))
9197 { 9596 {
9198 GtkEventController *controller = gtk_event_controller_key_new(); 9597 GtkEventController *controller = gtk_event_controller_key_new();
9199 gtk_widget_add_controller(GTK_WIDGET(window), controller); 9598 gtk_widget_add_controller(GTK_WIDGET(window), controller);
9200 g_signal_connect(G_OBJECT(controller), "key-pressed", G_CALLBACK(_dw_default_key_press_event), next); 9599 g_signal_connect(G_OBJECT(controller), "key-pressed", G_CALLBACK(_dw_default_key_press_event), next);
9201 } 9600 }
9601 DW_FUNCTION_RETURN_NOTHING;
9202 } 9602 }
9203 9603
9204 9604
9205 /* 9605 /*
9206 * Creates a new system notification if possible. 9606 * Creates a new system notification if possible.
9325 * Returns: 9725 * Returns:
9326 * NULL on error. A malloced buffer containing 9726 * NULL on error. A malloced buffer containing
9327 * the file path on success. 9727 * the file path on success.
9328 * 9728 *
9329 */ 9729 */
9330 char *dw_file_browse(const char *title, const char *defpath, const char *ext, int flags) 9730 DW_FUNCTION_DEFINITION(dw_file_browse, char *, const char *title, const char *defpath, const char *ext, int flags)
9731 DW_FUNCTION_ADD_PARAM4(title, defpath, ext, flags)
9732 DW_FUNCTION_RETURN(dw_file_browse, char *)
9733 DW_FUNCTION_RESTORE_PARAM4(title, const char *, defpath, const char *, ext, const char *, flags, int)
9331 { 9734 {
9332 GtkWidget *filew; 9735 GtkWidget *filew;
9333 9736
9334 GtkFileChooserAction action; 9737 GtkFileChooserAction action;
9335 GtkFileFilter *filter1 = NULL; 9738 GtkFileFilter *filter1 = NULL;
9336 GtkFileFilter *filter2 = NULL; 9739 GtkFileFilter *filter2 = NULL;
9337 gchar *button; 9740 gchar *button = NULL;
9338 char *filename = NULL; 9741 char *filename = NULL;
9339 char buf[1000]; 9742 char buf[1000];
9340 DWDialog *tmp = dw_dialog_new(NULL); 9743 DWDialog *tmp = dw_dialog_new(NULL);
9341 9744
9342 switch (flags ) 9745 switch (flags )
9353 action = GTK_FILE_CHOOSER_ACTION_SAVE; 9756 action = GTK_FILE_CHOOSER_ACTION_SAVE;
9354 button = _("_Save"); 9757 button = _("_Save");
9355 break; 9758 break;
9356 default: 9759 default:
9357 dw_messagebox( "Coding error", DW_MB_OK|DW_MB_ERROR, "dw_file_browse() flags argument invalid."); 9760 dw_messagebox( "Coding error", DW_MB_OK|DW_MB_ERROR, "dw_file_browse() flags argument invalid.");
9358 return NULL;
9359 break; 9761 break;
9360 } 9762 }
9361 9763
9362 filew = gtk_file_chooser_dialog_new ( title, 9764 if(button)
9363 NULL, 9765 {
9364 action, 9766 filew = gtk_file_chooser_dialog_new ( title,
9365 _("_Cancel"), GTK_RESPONSE_CANCEL, 9767 NULL,
9366 button, GTK_RESPONSE_ACCEPT, 9768 action,
9367 NULL); 9769 _("_Cancel"), GTK_RESPONSE_CANCEL,
9368 9770 button, GTK_RESPONSE_ACCEPT,
9369 if(ext) 9771 NULL);
9370 { 9772
9371 filter1 = gtk_file_filter_new(); 9773 if(ext)
9372 sprintf( buf, "*.%s", ext ); 9774 {
9373 gtk_file_filter_add_pattern( filter1, (gchar *)buf ); 9775 filter1 = gtk_file_filter_new();
9374 sprintf( buf, "\"%s\" files", ext ); 9776 sprintf( buf, "*.%s", ext );
9375 gtk_file_filter_set_name( filter1, (gchar *)buf ); 9777 gtk_file_filter_add_pattern( filter1, (gchar *)buf );
9376 filter2 = gtk_file_filter_new(); 9778 sprintf( buf, "\"%s\" files", ext );
9377 gtk_file_filter_add_pattern( filter2, (gchar *)"*" ); 9779 gtk_file_filter_set_name( filter1, (gchar *)buf );
9378 gtk_file_filter_set_name( filter2, (gchar *)"All Files" ); 9780 filter2 = gtk_file_filter_new();
9379 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter1 ); 9781 gtk_file_filter_add_pattern( filter2, (gchar *)"*" );
9380 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter2 ); 9782 gtk_file_filter_set_name( filter2, (gchar *)"All Files" );
9381 } 9783 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter1 );
9382 9784 gtk_file_chooser_add_filter( GTK_FILE_CHOOSER( filew ), filter2 );
9383 if(defpath) 9785 }
9384 { 9786
9385 GFile *path = g_file_new_for_path(defpath); 9787 if(defpath)
9386 9788 {
9387 /* See if the path exists */ 9789 GFile *path = g_file_new_for_path(defpath);
9388 if(path) 9790
9389 { 9791 /* See if the path exists */
9390 /* If the path is a directory... set the current folder */ 9792 if(path)
9391 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filew), path, NULL); 9793 {
9392 gtk_file_chooser_set_file(GTK_FILE_CHOOSER(filew), path, NULL); 9794 /* If the path is a directory... set the current folder */
9393 9795 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filew), path, NULL);
9394 g_object_unref(G_OBJECT(path)); 9796 gtk_file_chooser_set_file(GTK_FILE_CHOOSER(filew), path, NULL);
9395 } 9797
9396 } 9798 g_object_unref(G_OBJECT(path));
9397 9799 }
9398 gtk_widget_show(GTK_WIDGET(filew)); 9800 }
9399 g_signal_connect(G_OBJECT(filew), "response", G_CALLBACK(_dw_dialog_response), (gpointer)tmp); 9801
9400 9802 gtk_widget_show(GTK_WIDGET(filew));
9401 if(DW_POINTER_TO_INT(dw_dialog_wait(tmp)) == GTK_RESPONSE_ACCEPT) 9803 g_signal_connect(G_OBJECT(filew), "response", G_CALLBACK(_dw_dialog_response), (gpointer)tmp);
9402 { 9804
9403 GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(filew)); 9805 if(DW_POINTER_TO_INT(dw_dialog_wait(tmp)) == GTK_RESPONSE_ACCEPT)
9404 filename = g_file_get_path(file); 9806 {
9405 g_object_unref(G_OBJECT(file)); 9807 GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(filew));
9406 } 9808 filename = g_file_get_path(file);
9407 9809 g_object_unref(G_OBJECT(file));
9408 if(GTK_IS_WINDOW(filew)) 9810 }
9409 gtk_window_destroy(GTK_WINDOW(filew)); 9811
9410 return filename; 9812 if(GTK_IS_WINDOW(filew))
9813 gtk_window_destroy(GTK_WINDOW(filew));
9814 }
9815 DW_FUNCTION_RETURN_THIS(filename);
9411 } 9816 }
9412 9817
9413 9818
9414 /* 9819 /*
9415 * Execute and external program in a seperate session. 9820 * Execute and external program in a seperate session.
9620 /* 10025 /*
9621 * Create a new HTML window (widget) to be packed. 10026 * Create a new HTML window (widget) to be packed.
9622 * Parameters: 10027 * Parameters:
9623 * id: An ID to be used with dw_window_from_id() or 0L. 10028 * id: An ID to be used with dw_window_from_id() or 0L.
9624 */ 10029 */
9625 HWND dw_html_new(unsigned long id) 10030 DW_FUNCTION_DEFINITION(dw_html_new, HWND, DW_UNUSED(ULONG cid))
10031 DW_FUNCTION_ADD_PARAM1(cid)
10032 DW_FUNCTION_RETURN(dw_html_new, HWND)
10033 DW_FUNCTION_RESTORE_PARAM1(DW_UNUSED(cid), ULONG)
9626 { 10034 {
9627 GtkWidget *widget = NULL; 10035 GtkWidget *widget = NULL;
9628 #ifdef USE_WEBKIT 10036 #ifdef USE_WEBKIT
9629 WebKitWebView *web_view; 10037 WebKitWebView *web_view;
9630 WebKitSettings *settings; 10038 WebKitSettings *settings;
9633 settings = webkit_web_view_get_settings(web_view); 10041 settings = webkit_web_view_get_settings(web_view);
9634 /* Make sure java script is enabled */ 10042 /* Make sure java script is enabled */
9635 webkit_settings_set_enable_javascript(settings, TRUE); 10043 webkit_settings_set_enable_javascript(settings, TRUE);
9636 webkit_web_view_set_settings(web_view, settings); 10044 webkit_web_view_set_settings(web_view, settings);
9637 widget = (GtkWidget *)web_view; 10045 widget = (GtkWidget *)web_view;
10046 g_object_set_data(G_OBJECT(widget), "_dw_id", GINT_TO_POINTER(cid));
9638 gtk_widget_show(widget); 10047 gtk_widget_show(widget);
9639 #else 10048 #else
9640 dw_debug( "HTML widget not available; you do not have access to webkit.\n" ); 10049 dw_debug( "HTML widget not available; you do not have access to webkit.\n" );
9641 #endif 10050 #endif
9642 return widget; 10051 DW_FUNCTION_RETURN_THIS(widget);
9643 } 10052 }
9644 10053
9645 static void _dw_clipboard_callback(GObject *object, GAsyncResult *res, gpointer data) 10054 static void _dw_clipboard_callback(GObject *object, GAsyncResult *res, gpointer data)
9646 { 10055 {
9647 DWDialog *tmp = (DWDialog *)data; 10056 DWDialog *tmp = (DWDialog *)data;