Exemplo n.º 1
0
/*********************************************************************
*
*       LISTVIEW__SetSel
*/
void LISTVIEW__SetSel(LISTVIEW_Handle hObj, LISTVIEW_Obj* pObj, int NewSel) {
  int NumRows;
  NumRows = LISTVIEW__GetNumRows(pObj);
  if (NewSel >= NumRows) {
    NewSel = NumRows - 1;
  }
  if (NewSel < 0) {
    NewSel = -1;
  }
  if (NewSel != pObj->Sel) {
    char Disabled;
    LISTVIEW_ROW * pRow;
    pRow = (LISTVIEW_ROW *)GUI_ARRAY_GetpItem(&pObj->RowArray, NewSel);
    if (pRow) {
      Disabled = pRow->Disabled;
    } else {
      Disabled = 0;
    }
    if (Disabled == 0) {
      int OldSel;
      OldSel    = pObj->Sel;
      pObj->Sel = NewSel;
      if (LISTVIEW__UpdateScrollPos(hObj, pObj)) {
        LISTVIEW__InvalidateInsideArea(hObj, pObj);
      } else {
        LISTVIEW__InvalidateRow(hObj, pObj, OldSel);
        LISTVIEW__InvalidateRow(hObj, pObj, NewSel);
      }
      WM_NotifyParent(hObj, WM_NOTIFICATION_SEL_CHANGED);
    }
  }
}
Exemplo n.º 2
0
/*********************************************************************
*
*       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;
}
Exemplo n.º 3
0
/*********************************************************************
*
*       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();
    }
  }
}
Exemplo n.º 4
0
/*********************************************************************
*
*       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();
  }
}