⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listedit_deleterow.c

📁 在uc_GUI中增加的列表编辑框list_edit源代码
💻 C
字号:
/*
*********************************************************************************************************
*                                                uC/GUI
*                        Universal graphic software for embedded applications
*
*                       (c) Copyright 2002, Micrium Inc., Weston, FL
*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
*              礐/GUI is protected by international copyright laws. Knowledge of the
*              source code may not be used to write a similar product. This file may
*              only be used in accordance with a license and should not be redistributed
*              in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File        : LISTEDIT_DeleteRow.c
Purpose     : Implementation of LISTEDIT_DeleteRow
---------------------------END-OF-HEADER------------------------------
*/

#include "LISTEDIT_Private.h"

#if GUI_WINSUPPORT

/*********************************************************************
*
*       Static routines
*
**********************************************************************
*/
/*********************************************************************
*
*       _InvalidateRowAndBelow
*/
static void _InvalidateRowAndBelow(LISTEDIT_Handle hObj, LISTEDIT_Obj* pObj, int Sel) {
  if (Sel >= 0) {
  	int tmp;
    GUI_RECT Rect;
    int HeaderHeight, RowDistY;
    HeaderHeight = HEADER_GetHeight(pObj->hHeader);
    RowDistY     = LISTEDIT__GetRowDistY(pObj);
    WM_GetInsideRectExScrollbar(hObj, &Rect);
    Rect.y0 += HeaderHeight + (Sel - pObj->ScrollStateV.v) * RowDistY;
    //add by fzz 20060228
   // Uart_Printf("NumRows=%d,CurRow=%d\n",LISTEDIT_GetNumRows(hObj),Sel);
    //tmp=Rect.y0+((LISTEDIT_GetNumRows(hObj)-LISTEDIT_GetRowSel(hObj))*RowDistY);
    tmp=Rect.y0+((LISTEDIT_GetNumRows(hObj)+1-Sel)*RowDistY);
    Rect.y1=tmp<Rect.y1?tmp:Rect.y1;
    
    WM_InvalidateRect(hObj, &Rect);
  }
}

/*********************************************************************
*
*       Public routines
*
**********************************************************************
*/
/*********************************************************************
*
*       LISTEDIT_DeleteRow
*/
void LISTEDIT_DeleteRow(LISTEDIT_Handle hObj, unsigned Index) {
  if (hObj) {
    LISTEDIT_Obj* pObj;
    unsigned NumRows;
    WM_LOCK();
    pObj = LISTEDIT_H2P(hObj);
    NumRows = GUI_ARRAY_GetNumItems(&pObj->RowArray);
    if (Index < NumRows) {
      unsigned NumColumns, i;
      GUI_ARRAY* pRow;
      pRow = (GUI_ARRAY*)GUI_ARRAY_GetpItem(&pObj->RowArray, Index);
      /* Delete attached info items */
      NumColumns = GUI_ARRAY_GetNumItems(pRow);
      for (i = 0; i < NumColumns; i++) {
        LISTEDIT_ITEM * pItem;
        pItem = (LISTEDIT_ITEM *)GUI_ARRAY_GetpItem(pRow, i);
        if (pItem->hItemInfo) {
          GUI_ALLOC_Free(pItem->hItemInfo);
        }
      }
      /* Delete row */
      GUI_ARRAY_Delete(pRow);
      GUI_ARRAY_DeleteItem(&pObj->RowArray, Index);
      /* Adjust properties */
      if (pObj->RowSel == (signed int)Index) {
        pObj->RowSel = -1;
      }
      if (pObj->RowSel > (signed int)Index) {
        pObj->RowSel--;
      }
      if (LISTEDIT__UpdateScrollParas(hObj, pObj)) {
        LISTEDIT__InvalidateInsideArea(hObj, pObj);
      } else {
        _InvalidateRowAndBelow(hObj, pObj, Index);
      }
    }
    WM_UNLOCK();
  }
}


#else                            /* Avoid problems with empty object modules */
  void LISTEDIT_DeleteRow_C(void);
  void LISTEDIT_DeleteRow_C(void) {}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -