本文整理汇总了C++中GUI_ALLOC_h2p函数的典型用法代码示例。如果您正苦于以下问题:C++ GUI_ALLOC_h2p函数的具体用法?C++ GUI_ALLOC_h2p怎么用?C++ GUI_ALLOC_h2p使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GUI_ALLOC_h2p函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _GetpCellInfo
/*********************************************************************
*
* _GetpCellInfo
*/
static LISTVIEW_CELL_INFO* _GetpCellInfo(LISTVIEW_Handle hObj, unsigned Column, unsigned Row, unsigned int Index) {
LISTVIEW_CELL_INFO* pCellInfo = 0;
if (hObj) {
LISTVIEW_Obj* pObj;
pObj = LISTVIEW_H2P(hObj);
if (Index < GUI_COUNTOF(pCellInfo->aTextColor)) {
if ((Column < LISTVIEW__GetNumColumns(pObj)) && (Row < LISTVIEW__GetNumRows(pObj))) {
LISTVIEW_ROW* pRow;
LISTVIEW_CELL* pCell;
pRow = (LISTVIEW_ROW*) GUI_ARRAY_GetpItem(&pObj->RowArray, Row);
pCell = (LISTVIEW_CELL*) GUI_ARRAY_GetpItem(&pRow->CellArray, Column);
if (!pCell->hCellInfo) {
int i;
pCell->hCellInfo = GUI_ALLOC_AllocZero(sizeof(LISTVIEW_CELL_INFO));
pCellInfo = (LISTVIEW_CELL_INFO*) GUI_ALLOC_h2p(pCell->hCellInfo);
for (i = 0; i < GUI_COUNTOF(pCellInfo->aTextColor); i++) {
pCellInfo->aTextColor[i] = LISTVIEW_GetTextColor(hObj, i);
pCellInfo->aBkColor[i] = LISTVIEW_GetBkColor (hObj, i);
}
} else {
pCellInfo = (LISTVIEW_CELL_INFO*) GUI_ALLOC_h2p(pCell->hCellInfo);
}
}
}
}
return pCellInfo;
}
示例2: GUI_ARRAY_InsertBlankItem
/*********************************************************************
*
* GUI_ARRAY_InsertBlankItem
*
* Purpose:
* Inserts a blank element in a GUI_ARRAY.
*
* Parameters:
* Index Index of the element to insert before
* 0 means: Insert before first element
* 1 means: Insert before second element
*
* Return value:
* 1 if successful
* 0 if failed
*
* Notes:
* (1) Index changes
* The index of all items after the one inserted will change
* (Increment by 1)
*/
char GUI_ARRAY_InsertBlankItem(GUI_ARRAY* pThis, unsigned int Index) {
GUI_ARRAY_CHECK(pThis); /* Sanity checks at higher debug levels only */
if (Index >= (unsigned)pThis->NumItems) {
GUI_DEBUG_ERROROUT("GUI_ARRAY_InsertBlankItem: Illegal index");
} else {
WM_HMEM hNewBuffer;
hNewBuffer = GUI_ALLOC_AllocZero(sizeof(WM_HMEM) * (pThis->NumItems + 1));
if (hNewBuffer == 0) {
GUI_DEBUG_ERROROUT("GUI_ARRAY_InsertBlankItem: Failed to alloc buffer");
} else {
WM_HMEM *pOldBuffer;
WM_HMEM *pNewBuffer;
pNewBuffer = (WM_HMEM*) GUI_ALLOC_h2p(hNewBuffer);
pOldBuffer = (WM_HMEM*) GUI_ALLOC_h2p(pThis->haHandle);
memcpy(pNewBuffer, pOldBuffer, Index * sizeof(WM_HMEM));
memcpy(pNewBuffer + (Index + 1), pOldBuffer + Index, (pThis->NumItems - Index) * sizeof(WM_HMEM));
GUI_ALLOC_Free(pThis->haHandle);
pThis->haHandle = hNewBuffer;
pThis->NumItems++;
return 1; /* Successfull */
}
}
return 0; /* Failed */
}
示例3: _OnPaint
/*********************************************************************
*
* _OnPaint
*/
static void _OnPaint(GRAPH_DATA_Handle hDataObj, GUI_RECT * pRect) {
GUI_POINT * pData;
GRAPH_DATA_XY_OBJ * pDataXYObj;
GUI_USE_PARA(pRect);
pDataXYObj = (GRAPH_DATA_XY_OBJ *)GUI_ALLOC_h2p(hDataObj);
pData = (GUI_POINT *)GUI_ALLOC_h2p(pDataXYObj->hData);
if (pData) {
GUI_RECT Rect;
GRAPH_OBJ * pObj;
int xPos, yPos;
int BorderL, BorderT, BorderR, BorderB;
pObj = GRAPH_H2P(pDataXYObj->GraphDataObj.PaintObj.hGraph);
BorderL = pObj->Props.BorderL;
BorderT = pObj->Props.BorderT;
BorderR = pObj->Props.BorderR;
BorderB = pObj->Props.BorderB;
WM_GetInsideRectExScrollbar(pDataXYObj->GraphDataObj.PaintObj.hGraph, &Rect);
Rect.x0 += BorderL;
Rect.y0 += BorderT;
Rect.x1 -= BorderR;
Rect.y1 -= BorderB;
xPos = Rect.x0 + pDataXYObj->GraphDataObj.OffX;
yPos = Rect.y1 - pDataXYObj->GraphDataObj.OffY;
pObj = GRAPH_H2P(pDataXYObj->GraphDataObj.PaintObj.hGraph);
GUI_SetColor(pDataXYObj->GraphDataObj.Color);
GUI_SetPenSize(pDataXYObj->PenSize);
GUI_SetLineStyle(pDataXYObj->LineStyle);
_DrawPolyLine(pData, pDataXYObj->GraphDataObj.NumItems, xPos + pObj->ScrollStateH.v, yPos + pObj->ScrollStateV.v);
}
}
示例4: WM_LOCK
/*********************************************************************
*
* WM_CreateTimer
*
* Returns: 0 if failed, else != 0
* Parameters:
* hWin Window handle of the window to receive the WM_TIMER message
* UserId User defined Id. If not needed, use 0.
* Period Number of time units (ticks)
* Mode 0: one-shot
*
*/
int WM_CreateTimer (WM_HWIN hWin, int UserId, int Period, int Mode) {
int r = 0;
int TimerId;
GUI_HMEM hTimerLink;
TIMER_LINK* pLink;
WM_LOCK();
TimerId = GUI_X_CREATE_TIMER(Period, _OnTimer);
if (TimerId) {
hTimerLink = GUI_ALLOC_AllocZero(sizeof(TIMER_LINK));
if (hTimerLink) {
pLink = (TIMER_LINK*) GUI_ALLOC_h2p(hTimerLink);
/* Put new timer at beginning of the linked list */
pLink->hNext = _hFirst;
if (_hFirst) {
TIMER_LINK* pNext;
pNext = (TIMER_LINK*) GUI_ALLOC_h2p(_hFirst);
}
_hFirst = hTimerLink;
/* Fill in link data */
pLink->hWin = hWin;
pLink->TimerId = TimerId;
pLink->UserId = UserId;
r = 1; /* All right, we have successfully created a new timer */
}
}
/* Cleanup in case of problem */
if (r == 0) {
if (TimerId) {
GUI_X_DELETE_TIMER(TimerId);
}
}
WM_UNLOCK();
return r;
}
示例5: TEXT_CreateEx
/*********************************************************************
*
* TEXT_CreateEx
*/
TEXT_Handle TEXT_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent,
int WinFlags, int ExFlags, int Id, const char* pText)
{
TEXT_Handle hObj;
/* Create the window */
#if TEXT_SUPPORT_TRANSPARENCY
WinFlags |= WM_CF_HASTRANS;
#endif
WM_LOCK();
hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, TEXT_Callback,
sizeof(TEXT_Obj) - sizeof(WM_Obj));
if (hObj) {
TEXT_Obj* pObj;
WM_HMEM hMem = 0;
pObj = (TEXT_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
/* init widget specific variables */
WIDGET__Init(&pObj->Widget, Id, 0);
/* init member variables */
TEXT_INIT_ID(pObj);
if (pText) {
hMem = GUI_ALLOC_AllocZero(strlen(pText) + 1);
if (hMem) {
strcpy((char*) GUI_ALLOC_h2p(hMem), pText);
}
}
pObj->hpText = hMem;
pObj->Align = ExFlags;
pObj->Props = TEXT__DefaultProps;
} else {
GUI_DEBUG_ERROROUT_IF(hObj==0, "TEXT_Create failed")
}
WM_UNLOCK();
return hObj;
}
示例6: GRAPH_DATA_XY_Create
/*********************************************************************
*
* GRAPH_DATA_XY_Create
*/
GRAPH_DATA_Handle GRAPH_DATA_XY_Create(GUI_COLOR Color, unsigned MaxNumItems, GUI_POINT * pItems, unsigned NumItems) {
GRAPH_DATA_Handle hDataObj;
WM_LOCK();
hDataObj = GUI_ALLOC_AllocZero(sizeof(GRAPH_DATA_XY_OBJ));
if (hDataObj) {
GRAPH_DATA_XY_OBJ * pDataXYObj;
WM_HMEM hData;
int BufferSize;
BufferSize = sizeof(GUI_POINT) * MaxNumItems;
hData = GUI_ALLOC_AllocZero(BufferSize);
if (hData && pItems && NumItems) {
void * p;
p = GUI_ALLOC_h2p(hData);
memcpy(p, pItems, sizeof(GUI_POINT) * NumItems);
}
pDataXYObj = (GRAPH_DATA_XY_OBJ *)GUI_ALLOC_h2p(hDataObj);
pDataXYObj->hData = hData;
pDataXYObj->PenSize = 1;
pDataXYObj->GraphDataObj.Color = Color;
pDataXYObj->GraphDataObj.MaxNumItems = MaxNumItems;
pDataXYObj->GraphDataObj.NumItems = NumItems;
pDataXYObj->GraphDataObj.PaintObj.pfOnPaint = _OnPaint;
pDataXYObj->GraphDataObj.PaintObj.pfOnDelete = _OnDelete;
}
WM_UNLOCK();
return hDataObj;
}
示例7: _Sort
/*********************************************************************
*
* _Sort
*
* Purpose:
* Sorts the contents of the LISTVIEW by using the qsort algorithm.
* The compare function is called for each compare operation with valid
* pointers to cell data of the specified column.
*/
static int _Sort(LISTVIEW_Handle hObj) {
WM_HMEM hSortArray;
SORT_OBJECT SortObject;
int NumItems, NumItemsReq, i, Sel;
SortObject.pObj = LISTVIEW_H2P(hObj);
if (((SortObject.pObj->IsPresorted) && (SortObject.pObj->IsSorted)) || (SortObject.pObj->hSort == 0)) {
return 0;
}
SortObject.pSort = (LISTVIEW_SORT *)GUI_ALLOC_h2p(SortObject.pObj->hSort);
NumItemsReq = SortObject.pObj->RowArray.NumItems;
NumItems = SortObject.pSort->SortArrayNumItems;
Sel = _GetSelUnsorted(SortObject.pObj);
/* Adjust number of items in sort array */
if (NumItems != NumItemsReq) {
if (!SortObject.pSort->hSortArray) {
hSortArray = GUI_ALLOC_AllocZero(sizeof(SORT_TYPE) * NumItemsReq);
} else {
hSortArray = GUI_ALLOC_Realloc(SortObject.pSort->hSortArray, sizeof(SORT_TYPE) * NumItemsReq);
}
if (!hSortArray) {
return 1;
}
SortObject.pObj = LISTVIEW_H2P(hObj);
SortObject.pSort = (LISTVIEW_SORT *)GUI_ALLOC_h2p(SortObject.pObj->hSort);
SortObject.pSort->hSortArray = hSortArray;
}
SortObject.paSortArray = (SORT_TYPE *)GUI_ALLOC_h2p(SortObject.pSort->hSortArray);
if (SortObject.pObj->IsPresorted) {
/* Add new indices */
if (NumItems < NumItemsReq) {
SortObject.pObj->ReverseSort = 0; /* Reverse sort only allowed if listview is presorted and no rows are added */
for (i = NumItems; i < NumItemsReq; i++) {
*(SortObject.paSortArray + i) = i;
}
}
} else {
SortObject.pObj->ReverseSort = 0; /* Reverse sort only allowed if listview is presorted */
/* Fill with indices if not presorted */
for (i = 0; i < NumItemsReq; i++) {
*(SortObject.paSortArray + i) = i;
}
}
SortObject.pSort->SortArrayNumItems = NumItemsReq;
/* Sort only if more than one item is available */
if (NumItemsReq > 1) {
if (SortObject.pObj->ReverseSort) {
_Reverse(&SortObject);
} else {
_BubbleSort(0, NumItemsReq - 1, &SortObject);
}
_SetSelUnsorted(hObj, SortObject.pObj, Sel);
}
SortObject.pObj->IsPresorted = 1;
SortObject.pObj->IsSorted = 1;
HEADER_SetDirIndicator(SortObject.pObj->hHeader, SortObject.pObj->SortIndex, SortObject.pSort->Reverse);
return 0;
}
示例8: GRAPH_DATA_XY_AddPoint
/*********************************************************************
*
* GRAPH_DATA_XY_AddPoint
*/
void GRAPH_DATA_XY_AddPoint(GRAPH_DATA_Handle hDataObj, GUI_POINT * pPoint) {
GRAPH_DATA_XY_OBJ * pDataXYObj;
WM_LOCK();
pDataXYObj = (GRAPH_DATA_XY_OBJ *)GUI_ALLOC_h2p(hDataObj);
if (pDataXYObj) {
GUI_POINT * pData;
pData = (GUI_POINT *)GUI_ALLOC_h2p(pDataXYObj->hData);
GRAPH__AddValue(&pDataXYObj->GraphDataObj, pData, pPoint, sizeof(GUI_POINT));
}
WM_UNLOCK();
}
示例9: _GetpRow
/*********************************************************************
*
* _GetpRow
*/
static LISTVIEW_ROW * _GetpRow(LISTVIEW_Obj * pObj, int Index) {
if (pObj->hSort && (pObj->SortIndex >= 0)) {
LISTVIEW_SORT * pSort;
SORT_TYPE * pData;
pSort = (LISTVIEW_SORT *)GUI_ALLOC_h2p(pObj->hSort);
pData = (SORT_TYPE *)GUI_ALLOC_h2p(pSort->hSortArray);
if (Index >= pSort->SortArrayNumItems) {
return NULL;
}
return (LISTVIEW_ROW *)GUI_ARRAY_GetpItem(&pObj->RowArray, *(pData + Index));
} else {
return (LISTVIEW_ROW *)GUI_ARRAY_GetpItem(&pObj->RowArray, Index);
}
}
示例10: LISTBOX_SetItemDisabled
/*********************************************************************
*
* LISTBOX_SetItemDisabled
*/
void LISTBOX_SetItemDisabled(LISTBOX_Handle hObj, unsigned Index, int OnOff) {
if (hObj) {
unsigned NumItems;
LISTBOX_Obj* pObj;
WM_LOCK();
pObj = LISTBOX_H2P(hObj);
NumItems = LISTBOX__GetNumItems(pObj);
if (Index < NumItems) {
WM_HMEM hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, Index);
if (hItem) {
LISTBOX_ITEM * pItem = (LISTBOX_ITEM *)GUI_ALLOC_h2p(hItem);
if (OnOff) {
if (!(pItem->Status & LISTBOX_ITEM_DISABLED)) {
pItem->Status |= LISTBOX_ITEM_DISABLED;
LISTBOX__InvalidateItem(hObj, pObj, Index);
}
} else {
if (pItem->Status & LISTBOX_ITEM_DISABLED) {
pItem->Status &= ~LISTBOX_ITEM_DISABLED;
LISTBOX__InvalidateItem(hObj, pObj, Index);
}
}
}
}
WM_UNLOCK();
}
}
示例11: CHECKBOX_Callback
/*********************************************************************
*
* CHECKBOX_Callback
*/
void CHECKBOX_Callback (WM_MESSAGE *pMsg) {
CHECKBOX_Handle hObj;
CHECKBOX_Obj* pObj;
hObj = pMsg->hWin;
pObj = (CHECKBOX_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
/* Let widget handle the standard messages */
if (WIDGET_HandleActive(hObj, pMsg) == 0) {
return;
}
switch (pMsg->MsgId) {
case WM_KEY:
_OnKey(hObj, pObj, pMsg);
break;
case WM_PAINT:
GUI_DEBUG_LOG("CHECKBOX: _Callback(WM_PAINT)\n");
_Paint(pObj, hObj);
return;
case WM_TOUCH:
_OnTouch(hObj, pObj, pMsg);
break;
case WM_DELETE:
GUI_DEBUG_LOG("CHECKBOX: _Callback(WM_DELETE)\n");
_Delete(pObj);
break; /* No return here ... WM_DefaultProc needs to be called */
}
WM_DefaultProc(pMsg);
}
示例12: _Draw
/*********************************************************************
*
* _Draw
*/
static void _Draw(void) {
int x, y, xSize, ySize;
LCD_PIXELINDEX* pData;
const GUI_BITMAP GUI_UNI_PTR * pBM;
GUI_LOCK();
if (_hBuffer) {
/* Save bitmap data */
pBM = _pCursor->pBitmap;
pData = (LCD_PIXELINDEX*)GUI_ALLOC_h2p(_hBuffer);
xSize = _Rect.x1 - _Rect.x0 + 1;
ySize = _Rect.y1 - _Rect.y0 + 1;
for (y = 0; y < ySize; y++) {
for (x = 0; x < xSize; x++) {
int BitmapPixel;
*(pData + x) = _GetPixelIndex(_Rect.x0 + x, _Rect.y0 + y);
BitmapPixel = GUI_GetBitmapPixelIndex(pBM, x, y);
if (BitmapPixel) {
_SetPixelIndex(_Rect.x0 + x, _Rect.y0 + y, _Log2Phys(BitmapPixel));
}
}
pData += pBM->XSize;
}
}
GUI_UNLOCK();
}
示例13: DROPDOWN_InsertString
/*********************************************************************
*
* DROPDOWN_InsertString
*/
void DROPDOWN_InsertString(DROPDOWN_Handle hObj, const char * s, unsigned int Index) {
if (hObj && s) {
DROPDOWN_Obj* pObj;
unsigned int NumItems;
WM_LOCK();
pObj = DROPDOWN_H2P(hObj);
NumItems = DROPDOWN_GetNumItems(hObj);
if (Index < NumItems) {
WM_HMEM hItem;
hItem = GUI_ARRAY_InsertItem(&pObj->Handles, Index, strlen(s) + 1);
if (hItem) {
char * pBuffer = (char *)GUI_ALLOC_h2p(hItem);
strcpy(pBuffer, s);
}
WM_InvalidateWindow(hObj);
if (pObj->hListWin) {
LISTBOX_InsertString(pObj->hListWin, s, Index);
}
} else {
DROPDOWN_AddString(hObj, s);
if (pObj->hListWin) {
LISTBOX_AddString(pObj->hListWin, s);
}
}
WM_UNLOCK();
}
}
示例14: _DemoSineWave
/*******************************************************************
*
* _DemoSineWave
*/
static void _DemoSineWave(void) {
PARAM Param;
I16 * pStart;
int t0, Cnt = 0;
GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
GUI_HMEM hMem = GUI_ALLOC_AllocZero(405 * sizeof(I16));
GUI_SetColor(GUI_WHITE);
GUI_SetBkColor(GUI_RED);
GUI_ClearRect(0, 55, LCD_XSIZE, 75);
GUI_SetFont(&GUI_FontComic18B_1);
GUI_DispStringAt("Sine wave", 20, 55);
pStart = GUI_ALLOC_h2p(hMem);
_GetSineData(pStart, 405);
GUI_SetFont(&GUI_Font6x8);
t0 = GUI_GetTime();
while((GUI_GetTime() - t0) < 10000) {
int t1, tDiff2;
if (Cnt++ % 90) {
Param.aY++;
} else {
Param.aY = pStart;
}
t1 = GUI_GetTime();
GUI_MEMDEV_Draw(&Rect, _Draw2, &Param, 0, 0);
tDiff2 = GUI_GetTime() - t1;
if (tDiff2 < 100) {
GUI_Delay(100 - tDiff2);
}
}
GUI_ALLOC_Free(hMem);
}
示例15: _DemoRandomGraph
/*******************************************************************
*
* _DemoRandomGraph
*/
static void _DemoRandomGraph(void) {
PARAM Param;
int tDiff, t0;
GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
GUI_HMEM hMem = GUI_ALLOC_AllocZero((LCD_XSIZE - 20) * sizeof(I16));
GUI_SetColor(GUI_WHITE);
GUI_SetBkColor(GUI_RED);
GUI_ClearRect(0, 55, LCD_XSIZE, 75);
GUI_SetFont(&GUI_FontComic18B_1);
GUI_DispStringAt("Random graph", 20, 55);
GUI_Lock();
Param.aY = GUI_ALLOC_h2p(hMem);
GUI_SetFont(&GUI_Font6x8);
t0 = GUI_GetTime();
while((tDiff = (GUI_GetTime() - t0)) < 10000) {
int t1, tDiff2;
_GetRandomData(Param.aY, tDiff, (LCD_XSIZE - 20));
t1 = GUI_GetTime();
GUI_MEMDEV_Draw(&Rect, _Draw, &Param, 0, 0);
tDiff2 = GUI_GetTime() - t1;
if (tDiff2 < 100) {
GUI_Delay(100 - tDiff2);
}
}
GUI_Unlock();
GUI_ALLOC_Free(hMem);
}