/********************************************************************* * * RADIO_SetText */ void RADIO_SetText(RADIO_Handle hObj, const char* pText, unsigned Index) { if (hObj) { RADIO_Obj* pObj; WM_LOCK(); pObj = RADIO_H2P(hObj); if (Index < (unsigned)pObj->NumItems) { GUI_ARRAY_SetItem(&pObj->TextArray, Index, pText, pText ? (GUI__strlen(pText) + 1) : 0); WM_InvalidateWindow(hObj); } WM_UNLOCK(); } }
/********************************************************************* * * LISTVIEW_AddRow */ int LISTVIEW_AddRow(LISTVIEW_Handle hObj, const GUI_ConstString* ppText) { int r = 0; if (hObj) { LISTVIEW_Obj* pObj; WM_LOCK(); pObj = LISTVIEW_H2P(hObj); /* Add row item to the GUI_ARRAY */ if (GUI_ARRAY_AddItem(&pObj->RowArray, NULL, sizeof(LISTVIEW_ROW)) == 0) { LISTVIEW_ROW* pRow; int i, RowIndex, NumColumns, NumBytes; const char* s; pObj = LISTVIEW_H2P(hObj); /* Restore after allocating memory */ RowIndex = LISTVIEW__GetNumRows(pObj) - 1; NumColumns = LISTVIEW__GetNumColumns(pObj); pRow = (LISTVIEW_ROW*) GUI_ARRAY_GetpItem(&pObj->RowArray, RowIndex); GUI_ARRAY_CREATE(&pRow->CellArray); /* Add columns for the new row */ for (i = 0; i < NumColumns; i++) { LISTVIEW_CELL* pCell; s = (ppText) ? *ppText++ : 0; if (s == 0) { ppText = 0; } NumBytes = GUI__strlen(s) + 1; /* 0 if no string is specified (s == NULL) */ if (GUI_ARRAY_AddItem(&pRow->CellArray, NULL, sizeof(LISTVIEW_CELL) + NumBytes)) { r = 1; break; } pObj = LISTVIEW_H2P(hObj); /* Restore after allocating memory */ pRow = (LISTVIEW_ROW*) GUI_ARRAY_GetpItem(&pObj->RowArray, RowIndex); /* Restore after allocating memory */ pCell = (LISTVIEW_CELL*) GUI_ARRAY_GetpItem(&pRow->CellArray, i); if (NumBytes > 1) { strcpy(pCell->acText, s); } } pObj->IsSorted = 0; LISTVIEW__UpdateScrollParas(hObj, pObj); if (pObj->hSort && (pObj->SortIndex >= 0)) { LISTVIEW__InvalidateInsideArea(hObj, pObj); } else { LISTVIEW__InvalidateRow(hObj, pObj, RowIndex); } } else { r = 1; } WM_UNLOCK(); } return r; }
int GUI__SetText(GUI_HMEM* phText, const char* s) { int r = 0; if (GUI__strcmp_hp(*phText, s) != 0) { /* Make sure we have a quick out if nothing changes */ GUI_HMEM hMem; hMem = GUI_ALLOC_AllocNoInit(GUI__strlen(s) + 1); if (hMem) { char* pMem; pMem = (char*) GUI_ALLOC_h2p(hMem); strcpy(pMem, s); GUI_ALLOC_FreePtr(phText); *phText = hMem; r = 1; } } return r; }
/********************************************************************* * * LISTVIEW_SetItemText */ void LISTVIEW_SetItemText(LISTVIEW_Handle hObj, unsigned Column, unsigned Row, const char * s) { if (hObj) { if ((Column < LISTVIEW_GetNumColumns(hObj)) && (Row < LISTVIEW_GetNumRows(hObj))) { int NumBytes; LISTVIEW_ITEM * pItem; LISTVIEW_Obj * pObj; WM_LOCK(); pObj = LISTVIEW_H2P(hObj); NumBytes = GUI__strlen(s) + 1; pItem = (LISTVIEW_ITEM *)GUI_ARRAY_ResizeItem((GUI_ARRAY *)GUI_ARRAY_GetpItem(&pObj->RowArray, Row), Column, sizeof(LISTVIEW_ITEM) + NumBytes); if (NumBytes > 1) { strcpy(pItem->acText, s); } LISTVIEW__InvalidateRow(hObj, pObj, Row); WM_UNLOCK(); } } }
/********************************************************************* * * LISTVIEW_AddRow */ void LISTVIEW_AddRow(LISTVIEW_Handle hObj, const GUI_ConstString* ppText) { if (hObj) { LISTVIEW_Obj* pObj; int NumRows; WM_LOCK(); pObj = LISTVIEW_H2P(hObj); NumRows = GUI_ARRAY_GetNumItems(&pObj->RowArray); /* Create GUI_ARRAY for the new row */ if (GUI_ARRAY_AddItem(&pObj->RowArray, NULL, sizeof(GUI_ARRAY)) == 0) { int i, NumColumns, NumBytes; GUI_ARRAY* pRow; const char* s; GUI_ARRAY_CREATE((GUI_ARRAY *)GUI_ARRAY_GetpItem(&pObj->RowArray, NumRows)); /* For higher debug levels only */ /* Add columns for the new row */ NumColumns = HEADER_GetNumItems(pObj->hHeader); for (i = 0; i < NumColumns; i++) { LISTVIEW_ITEM * pItem; pRow = (GUI_ARRAY *)GUI_ARRAY_GetpItem(&pObj->RowArray, NumRows); s = (ppText) ? *ppText++ : 0; if (s == 0) { ppText = 0; } NumBytes = GUI__strlen(s) + 1; /* 0 if no string is specified (s == NULL) */ GUI_ARRAY_AddItem(pRow, NULL, sizeof(LISTVIEW_ITEM) + NumBytes); pItem = (LISTVIEW_ITEM *)GUI_ARRAY_GetpItem(pRow, i); if (NumBytes > 1) { strcpy(pItem->acText, s); } } LISTVIEW__UpdateScrollParas(hObj, pObj); LISTVIEW__InvalidateRow(hObj, pObj, NumRows); } WM_UNLOCK(); } }