diff -r 59758314f811 -r d4524d6a4472 Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/icons_8c_source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/icons_8c_source.html Fri Jun 11 15:24:34 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ - - -
- -00001 /* -00002 * icons.c -00003 * Copyright (C) 1998-2001 A.J. van Os; Released under GPL -00004 * -00005 * Description: -00006 * Update window icons -00007 */ -00008 -00009 #include <string.h> -00010 #include "DeskLib:Error.h" -00011 #include "DeskLib:WimpSWIs.h" -00012 #include "antiword.h" -00013 -00014 void -00015 vUpdateIcon(window_handle tWindow, icon_block *pIcon) -00016 { -00017 window_redrawblock tRedraw; -00018 BOOL bMore; -00019 -00020 tRedraw.window = tWindow; -00021 tRedraw.rect = pIcon->workarearect; -00022 Error_CheckFatal(Wimp_UpdateWindow(&tRedraw, &bMore)); -00023 while (bMore) { -00024 Error_CheckFatal(Wimp_PlotIcon(pIcon)); -00025 Error_CheckFatal(Wimp_GetRectangle(&tRedraw, &bMore)); -00026 } -00027 } /* end of vUpdateIcon */ -00028 -00029 void -00030 vUpdateRadioButton(window_handle tWindow, icon_handle tIconNumber, -00031 BOOL bSelected) -00032 { -00033 icon_block tIcon; -00034 -00035 Error_CheckFatal(Wimp_GetIconState(tWindow, tIconNumber, &tIcon)); -00036 DBG_DEC(tIconNumber); -00037 DBG_HEX(tIcon.flags.data.selected); -00038 if (bSelected == (tIcon.flags.data.selected == 1)) { -00039 /* No update needed */ -00040 return; -00041 } -00042 Error_CheckFatal(Wimp_SetIconState(tWindow, tIconNumber, -00043 bSelected ? 0x00200000 : 0, 0x00200000)); -00044 vUpdateIcon(tWindow, &tIcon); -00045 } /* end of vUpdateRadioButton */ -00046 -00047 /* -00048 * vUpdateWriteable - update a writeable icon with a string -00049 */ -00050 void -00051 vUpdateWriteable(window_handle tWindow, icon_handle tIconNumber, -00052 const char *szString) -00053 { -00054 icon_block tIcon; -00055 caret_block tCaret; -00056 int iLen; -00057 -00058 fail(szString == NULL); -00059 -00060 NO_DBG_DEC(tIconNumber); -00061 NO_DBG_MSG(szString); -00062 -00063 Error_CheckFatal(Wimp_GetIconState(tWindow, tIconNumber, &tIcon)); -00064 NO_DBG_HEX(tIcon.flags); -00065 if (!tIcon.flags.data.text || !tIcon.flags.data.indirected) { -00066 werr(1, "Icon %d must be indirected text", (int)tIconNumber); -00067 return; -00068 } -00069 strncpy(tIcon.data.indirecttext.buffer, -00070 szString, -00071 tIcon.data.indirecttext.bufflen - 1); -00072 /* Ensure the caret is behind the last character of the text */ -00073 Error_CheckFatal(Wimp_GetCaretPosition(&tCaret)); -00074 if (tCaret.window == tWindow && tCaret.icon == tIconNumber) { -00075 iLen = strlen(tIcon.data.indirecttext.buffer); -00076 if (tCaret.index != iLen) { -00077 tCaret.index = iLen; -00078 Error_CheckFatal(Wimp_SetCaretPosition(&tCaret)); -00079 } -00080 } -00081 Error_CheckFatal(Wimp_SetIconState(tWindow, tIconNumber, 0, 0)); -00082 vUpdateIcon(tWindow, &tIcon); -00083 } /* end of vUpdateWriteable */ -00084 -00085 /* -00086 * vUpdateWriteableNumber - update a writeable icon with a number -00087 */ -00088 void -00089 vUpdateWriteableNumber(window_handle tWindow, icon_handle tIconNumber, -00090 int iNumber) -00091 { -00092 char szTmp[1+3*sizeof(int)+1]; -00093 -00094 (void)sprintf(szTmp, "%d", iNumber); -00095 vUpdateWriteable(tWindow, tIconNumber, szTmp); -00096 } /* end of vUpdateWriteableNumber */ -