/********************************************************************* * * LISTBOX_CreateEx */ LISTBOX_Handle LISTBOX_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, const GUI_ConstString* ppText) { LISTBOX_Handle hObj; GUI_USE_PARA(ExFlags); hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, _LISTBOX_Callback, sizeof(LISTBOX_Obj) - sizeof(WM_Obj)); if (hObj) { LISTBOX_Obj* pObj; WM_LOCK(); pObj = LISTBOX_H2P(hObj); /* Init sub-classes */ GUI_ARRAY_CREATE(&pObj->ItemArray); /* init widget specific variables */ WIDGET__Init(&pObj->Widget, Id, WIDGET_STATE_FOCUSSABLE); pObj->Props = LISTBOX_DefaultProps; if (ppText) { /* init member variables */ /* Set non-zero attributes */ LISTBOX_SetText(hObj, ppText); } INIT_ID(pObj); LISTBOX_UpdateScrollers(hObj); WM_UNLOCK(); } return hObj; }
/********************************************************************* * * LISTVIEW_CreateEx */ LISTVIEW_Handle LISTVIEW_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id) { LISTVIEW_Handle hObj; GUI_USE_PARA(ExFlags); /* Create the window */ if ((xsize == 0) && (ysize == 0) && (x0 == 0) && (y0 == 0)) { GUI_RECT Rect; WM_GetClientRectEx(hParent, &Rect); xsize = Rect.x1 - Rect.x0 + 1; ysize = Rect.y1 - Rect.y0 + 1; } hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, &_LISTVIEW_Callback, sizeof(LISTVIEW_Obj) - sizeof(WM_Obj)); if (hObj) { LISTVIEW_Obj* pObj; WM_LOCK(); pObj = LISTVIEW_H2P(hObj); /* Init sub-classes */ GUI_ARRAY_CREATE(&pObj->RowArray); GUI_ARRAY_CREATE(&pObj->AlignArray); /* Init widget specific variables */ WIDGET__Init(&pObj->Widget, Id, WIDGET_STATE_FOCUSSABLE); /* Init member variables */ LISTVIEW_INIT_ID(pObj); pObj->Props = LISTVIEW_DefaultProps; pObj->ShowGrid = 0; pObj->RowDistY = 0; pObj->Sel = -1; pObj->LBorder = 1; pObj->RBorder = 1; pObj->hHeader = HEADER_CreateEx(0, 0, 0, 0, hObj, WM_CF_SHOW, 0, 0); LISTVIEW__UpdateScrollParas(hObj, pObj); WM_UNLOCK(); } else { GUI_DEBUG_ERROROUT_IF(hObj==0, "LISTVIEW_Create failed") } return hObj; }
/********************************************************************* * * RADIO_CreateEx */ RADIO_Handle RADIO_CreateEx(int x0, int y0, int xSize, int ySize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id, int NumItems, int Spacing) { RADIO_Handle hObj; int Height, i; /* Calculate helper variables */ Height = RADIO__apDefaultImage[0]->YSize + RADIO_BORDER * 2; Spacing = (Spacing <= 0) ? 20 : Spacing; NumItems = (NumItems <= 0) ? 2 : NumItems; if (ySize == 0) { ySize = Height + ((NumItems - 1) * Spacing); } if (xSize == 0) { xSize = RADIO__apDefaultImage[0]->XSize + RADIO_BORDER * 2; } #if WM_SUPPORT_TRANSPARENCY WinFlags |= WM_CF_HASTRANS; #endif /* Create the window */ hObj = WM_CreateWindowAsChild(x0, y0, xSize, ySize, hParent, WinFlags, _RADIO_Callback, sizeof(RADIO_Obj) - sizeof(WM_Obj)); if (hObj) { RADIO_Obj* pObj; WM_LOCK(); pObj = RADIO_H2P(hObj); /* Init sub-classes */ GUI_ARRAY_CREATE(&pObj->TextArray); for (i = 0; i < NumItems; i++) { GUI_ARRAY_AddItem(&pObj->TextArray, NULL, 0); } /* Init widget specific variables */ ExFlags &= RADIO_TEXTPOS_LEFT; WIDGET__Init(&pObj->Widget, Id, WIDGET_STATE_FOCUSSABLE | ExFlags); /* Init member variables */ RADIO_INIT_ID(pObj); pObj->apBmRadio[0] = RADIO__apDefaultImage[0]; pObj->apBmRadio[1] = RADIO__apDefaultImage[1]; pObj->pBmCheck = RADIO__pDefaultImageCheck; pObj->pFont = RADIO__pDefaultFont; pObj->TextColor = RADIO__DefaultTextColor; pObj->BkColor = WM_GetBkColor(hParent); pObj->NumItems = NumItems; pObj->Spacing = Spacing; pObj->Height = Height; WM_UNLOCK(); } else { GUI_DEBUG_ERROROUT_IF(hObj==0, "RADIO_Create failed") } return hObj; }
/********************************************************************* * * 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; }
/********************************************************************* * * 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(); } }
/********************************************************************* * * DROPDOWN_CreateEx */ DROPDOWN_Handle DROPDOWN_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags, int Id) { DROPDOWN_Handle hObj; hObj = WM_CreateWindowAsChild(x0, y0, xsize, -1, hParent, WinFlags, _DROPDOWN_Callback, sizeof(DROPDOWN_Obj) - sizeof(WM_Obj)); if (hObj) { DROPDOWN_Obj* pObj; WM_LOCK(); pObj = DROPDOWN_H2P(hObj); /* Init sub-classes */ GUI_ARRAY_CREATE(&pObj->Handles); /* init widget specific variables */ WIDGET__Init(&pObj->Widget, Id, WIDGET_STATE_FOCUSSABLE); pObj->Flags = ExFlags; pObj->Props = DROPDOWN__DefaultProps; pObj->ScrollbarWidth = 0; INIT_ID(pObj); pObj->ySizeEx = ysize; DROPDOWN__AdjustHeight(hObj, pObj); WM_UNLOCK(); } return hObj; }