3 * Copyright (C) 1998-2001 A.J. van Os; Released under GPL
10 #include "DeskLib:Error.h"
11 #include "DeskLib:WimpSWIs.h"
15 vUpdateIcon(window_handle tWindow
, icon_block
*pIcon
)
17 window_redrawblock tRedraw
;
20 tRedraw
.window
= tWindow
;
21 tRedraw
.rect
= pIcon
->workarearect
;
22 Error_CheckFatal(Wimp_UpdateWindow(&tRedraw
, &bMore
));
24 Error_CheckFatal(Wimp_PlotIcon(pIcon
));
25 Error_CheckFatal(Wimp_GetRectangle(&tRedraw
, &bMore
));
27 } /* end of vUpdateIcon */
30 vUpdateRadioButton(window_handle tWindow
, icon_handle tIconNumber
,
35 Error_CheckFatal(Wimp_GetIconState(tWindow
, tIconNumber
, &tIcon
));
37 DBG_HEX(tIcon
.flags
.data
.selected
);
38 if (bSelected
== (tIcon
.flags
.data
.selected
== 1)) {
39 /* No update needed */
42 Error_CheckFatal(Wimp_SetIconState(tWindow
, tIconNumber
,
43 bSelected
? 0x00200000 : 0, 0x00200000));
44 vUpdateIcon(tWindow
, &tIcon
);
45 } /* end of vUpdateRadioButton */
48 * vUpdateWriteable - update a writeable icon with a string
51 vUpdateWriteable(window_handle tWindow
, icon_handle tIconNumber
,
58 fail(szString
== NULL
);
60 NO_DBG_DEC(tIconNumber
);
63 Error_CheckFatal(Wimp_GetIconState(tWindow
, tIconNumber
, &tIcon
));
64 NO_DBG_HEX(tIcon
.flags
);
65 if (!tIcon
.flags
.data
.text
|| !tIcon
.flags
.data
.indirected
) {
66 werr(1, "Icon %d must be indirected text", (int)tIconNumber
);
69 strncpy(tIcon
.data
.indirecttext
.buffer
,
71 tIcon
.data
.indirecttext
.bufflen
- 1);
72 /* Ensure the caret is behind the last character of the text */
73 Error_CheckFatal(Wimp_GetCaretPosition(&tCaret
));
74 if (tCaret
.window
== tWindow
&& tCaret
.icon
== tIconNumber
) {
75 iLen
= strlen(tIcon
.data
.indirecttext
.buffer
);
76 if (tCaret
.index
!= iLen
) {
78 Error_CheckFatal(Wimp_SetCaretPosition(&tCaret
));
81 Error_CheckFatal(Wimp_SetIconState(tWindow
, tIconNumber
, 0, 0));
82 vUpdateIcon(tWindow
, &tIcon
);
83 } /* end of vUpdateWriteable */
86 * vUpdateWriteableNumber - update a writeable icon with a number
89 vUpdateWriteableNumber(window_handle tWindow
, icon_handle tIconNumber
,
92 char szTmp
[1+3*sizeof(int)+1];
94 (void)sprintf(szTmp
, "%d", iNumber
);
95 vUpdateWriteable(tWindow
, tIconNumber
, szTmp
);
96 } /* end of vUpdateWriteableNumber */