/********************************************************************* * * _InitDialogSelect */ static void _InitDialogSelect(WM_HWIN hWin) { WM_HWIN hItem; int i; i = 0; // // Init framewindow // FRAMEWIN_SetFont(hWin, &GUI_Font10_ASCII); FRAMEWIN_SetTitleHeight(hWin, 14); FRAMEWIN_SetMoveable(hWin, 1); // // Init listbox items // hItem = WM_GetDialogItem(hWin, GUI_ID_LISTVIEW0); WM_SetScrollbarV(hItem, 1); LISTVIEW_SetGridVis(hItem, 1); LISTVIEW_SetLBorder(hItem, 3); LISTVIEW_SetRBorder(hItem, 3); LISTVIEW_AddColumn(hItem, 80, "Make", GUI_TA_LEFT); LISTVIEW_AddColumn(hItem, 100, "Options", GUI_TA_LEFT); while (_acItems[i][0][0]) { _AddListviewItem(hItem, _acItems[i][0], _acItems[i][1]); i++; } }
/********************************************************************* * * _InitListview * * Purpose: * Adds some data to the listview widget */ static void _InitListview(WM_HWIN hList) { int i; HEADER_SetDragLimit(LISTVIEW_GetHeader(hList), 1); LISTVIEW_SetAutoScrollV(hList, 1); LISTVIEW_SetGridVis(hList, 1); LISTVIEW_SetRBorder(hList, 5); LISTVIEW_SetLBorder(hList, 5); for (i = 0; i < 3; i++) { LISTVIEW_AddColumn(hList, _aColProps[i].Width, _aColProps[i].pText, _aColProps[i].Align); LISTVIEW_SetCompareFunc(hList, i, _aColProps[i].fpCompare); } LISTVIEW_EnableSort(hList); }
/********************************************************************* * * _cbDialog * * Function description * Callback routine of dialog */ static void _cbDialog(WM_MESSAGE * pMsg) { static WM_HWIN hCellEdit = 0; CELL_EDIT_ORG CellEditOrg; WM_KEY_INFO * pKeyInfo; GUI_RECT ItemRect; WM_HWIN hDlg; WM_HWIN hItem; char acItemText[LEN_ITEM_TEXT]; int CheckState; int NCode; int Id; int i; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Set listview properties // hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0); WM_SetCallback(hItem, _cbList); HEADER_SetDragLimit(LISTVIEW_GetHeader(hItem), 1); LISTVIEW_SetAutoScrollV(hItem, 1); LISTVIEW_SetGridVis(hItem, 1); LISTVIEW_SetRBorder(hItem, 5); LISTVIEW_SetLBorder(hItem, 5); for (i = 0; i < 3; i++) { LISTVIEW_AddColumn(hItem, _aColProps[i].Width, _aColProps[i].pText, _aColProps[i].Align); LISTVIEW_SetCompareFunc(hItem, i, _aColProps[i].fpCompare); } LISTVIEW_EnableSort(hItem); for (i = 0; i < 6; i++) { if (_AddRow(hItem, 1)) { break; } } // // Set radio button text // hItem = WM_GetDialogItem(hDlg, GUI_ID_RADIO0); RADIO_SetText(hItem, "Sorted", 0); RADIO_SetText(hItem, "Unsorted", 1); // // Init checkbox text // hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0); CHECKBOX_SetTextAlign(hItem, GUI_TA_LEFT); CHECKBOX_SetText(hItem, "Cell select"); break; case WM_KEY: hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0); if (pMsg->hWinSrc == hItem) { pKeyInfo = (WM_KEY_INFO *)pMsg->Data.p; if (pKeyInfo->PressedCnt == 0) { if (pKeyInfo->Key == GUI_KEY_ENTER) { if (hCellEdit == 0) { CellEditOrg.Row = LISTVIEW_GetSel(hItem); CellEditOrg.Col = LISTVIEW_GetSelCol(hItem); LISTVIEW_GetItemRect(hItem, CellEditOrg.Col, CellEditOrg.Row, &ItemRect); LISTVIEW_GetItemTextSorted(hItem, CellEditOrg.Col, CellEditOrg.Row, acItemText, LEN_ITEM_TEXT); hCellEdit = EDIT_CreateUser(ItemRect.x0, ItemRect.y0, ItemRect.x1 - ItemRect.x0 + 2, ItemRect.y1 - ItemRect.y0 + 1, hItem, WM_CF_SHOW, 0, 0, LEN_ITEM_TEXT, sizeof(CELL_EDIT_ORG)); EDIT_SetUserData(hCellEdit, &CellEditOrg, sizeof(CELL_EDIT_ORG)); WIDGET_SetEffect(hCellEdit, &WIDGET_Effect_Simple); WM_SetCallback(hCellEdit, _cbCellEdit); WM_SetFocus(hCellEdit); EDIT_SetText(hCellEdit, acItemText); } } } } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (NCode) { case WM_NOTIFICATION_CHILD_DELETED: if (pMsg->hWinSrc == hCellEdit) { hCellEdit = 0; } break; case WM_NOTIFICATION_VALUE_CHANGED: switch (Id) { case GUI_ID_RADIO0: // // Enable/Disable sorting // hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0); switch (RADIO_GetValue(WM_GetDialogItem(hDlg, GUI_ID_RADIO0))) { case 0: LISTVIEW_EnableSort(hItem); break; default: LISTVIEW_DisableSort(hItem); break; } break; } break; case WM_NOTIFICATION_RELEASED: switch (Id) { case GUI_ID_BUTTON0: // // Add new row // hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0); _AddRow(hItem, 0); break; case GUI_ID_BUTTON1: // // Insert new row // hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0); i = LISTVIEW_GetSelUnsorted(hItem); _AddRow(hItem, 1); if (i >= 0) { LISTVIEW_SetSelUnsorted(hItem, i + 1); } break; case GUI_ID_BUTTON2: // // Delete row // hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0); i = LISTVIEW_GetSelUnsorted(hItem); LISTVIEW_DeleteRow(hItem, (i >= 0) ? i : 0); break; case GUI_ID_OK: // // End dialog // GUI_EndDialog(hDlg, 0); break; case GUI_ID_CHECK0: // // Enable/Disable cell selection // hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0); CheckState = CHECKBOX_GetState(hItem); hItem = WM_GetDialogItem(hDlg, GUI_ID_LISTVIEW0); if (CheckState) { LISTVIEW_EnableCellSelect(hItem, 1); } else { LISTVIEW_EnableCellSelect(hItem, 0); } break; } break; } break; default: WM_DefaultProc(pMsg); } }