/* 辅助函数-将TabPage还原回ChildPanel */ int ConvertTabPageToChildPanel(int panel, int tab, int tabIndex){ int childPanel, tabPanel, ctrl; char title[256]; //Get the tab-page label and handle GetTabPageAttribute(panel, tab, tabIndex, ATTR_LABEL_TEXT, title); GetPanelHandleFromTabPage(panel, tab, tabIndex, &tabPanel); //Create new child panel and set its attributes childPanel = createChildPanel(title, tabIndex); //Get the first control in the tab-page to convert. GetPanelAttribute(tabPanel, ATTR_PANEL_FIRST_CTRL, &ctrl); while(ctrl != 0){ //Duplicate the control to the child panel DuplicateCtrl(tabPanel, ctrl, childPanel, 0, VAL_KEEP_SAME_POSITION, VAL_KEEP_SAME_POSITION); //Get the next control to duplicate GetCtrlAttribute(tabPanel, ctrl, ATTR_NEXT_CTRL, &ctrl); } return childPanel; }
STD_ERROR DLLEXPORT GRAPH_AddLabel( void *Data , double X_Position , double Y_Position , char *szLabelText , int color , int label_type ) { STD_ERROR StdError = {0}; int iStart_Y = 0, iStart_X = 0, iStop_Y = 0, iStop_X = 0, iPointLeft = 0, iPointTop = 0; tsLabelItem *pCurrentLabel = NULL, *pReferenceLabel = NULL; int derection = 0, temp = 0; int min_digits = 0, min_digits_counts = 0, max_digits = 0, max_digits_counts = 0, x_offset = 0; double xPosition = 0.0, yPosition = 0.0; tsPlotGraphData *pData = NULL; SetBreakOnLibraryErrors (0); IF ( (Data == NULL) , "Pointer passed NULL"); pData = (tsPlotGraphData*)Data; IF (( pData->panel == 0 ) , "No Graph Data Created."); IF (( szLabelText == 0 ) , "Label Text is NULL pointer."); xPosition = X_Position; yPosition = Y_Position; pCurrentLabel = &pData->Labels; if ( pCurrentLabel->controlID ) do { if ( pCurrentLabel->pNextLabel == NULL ) { CALLOC_ERR( pCurrentLabel->pNextLabel , 1 , sizeof(tsLabelItem)); pCurrentLabel = pCurrentLabel->pNextLabel; break; } else { pCurrentLabel = pCurrentLabel->pNextLabel; } } while(pCurrentLabel); switch(label_type) { case 1: pCurrentLabel->controlID = DuplicateCtrl ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , pData->panel , szLabelText , 0 , 0 ); break; default: pCurrentLabel->controlID = DuplicateCtrl ( pData->panel , GRAPH_BUIL_UP_LABEL , pData->panel , szLabelText , 0 , 0 ); break; } GetCtrlAttribute ( pData->panel , GRAPH_BUIL_UP_LABEL , ATTR_TOP , &iStop_Y ); GetCtrlAttribute ( pData->panel , GRAPH_BUIL_UP_LABEL , ATTR_LEFT , &iStart_X ); GetCtrlAttribute ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , ATTR_TOP , &iStart_Y ); GetCtrlAttribute ( pData->panel , GRAPH_BUIL_RIGHT_LABEL , ATTR_LEFT , &iStop_X ); GetCtrlAttribute ( pData->panel , pData->control , ATTR_POINTS_PER_SCREEN, &temp ); X_Position = ( X_Position - pData->start_x ) / ( pData->stop_x - pData->start_x ); Y_Position = ( Y_Position - pData->y_axis_min ) / ( pData->y_axis_max - pData->y_axis_min ); Y_Position = 1.0 - Y_Position; min_digits = pData->y_axis_min; min_digits_counts = 0; max_digits = pData->y_axis_max; max_digits_counts = 0; do { min_digits /= 10; min_digits_counts++; }while(min_digits); do { max_digits /= 10; max_digits_counts++; }while(max_digits); if (( max_digits_counts > min_digits_counts ) || ( pData->y_axis_min >= 0.0 )) { max_digits_counts--; x_offset = max_digits_counts * 6; // 6 digit points } else { min_digits_counts--; x_offset = min_digits_counts * 6; // 6 digit points x_offset += 3; // - points } iPointLeft = (( iStop_X - iStart_X ) * X_Position ) + iStart_X + x_offset; iPointTop = (( iStop_Y - iStart_Y ) * Y_Position ) + iStart_Y; SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_TOP , iPointTop ); SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LEFT , iPointLeft ); if ( color ) { SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_OFF_COLOR , color ); SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_BGCOLOR , color ); } GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_LEFT , &pCurrentLabel->left ); GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_TOP , &pCurrentLabel->top ); GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_HEIGHT , &pCurrentLabel->bottom ); GetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_WIDTH , &pCurrentLabel->right ); pCurrentLabel->bottom += pCurrentLabel->top; pCurrentLabel->right += pCurrentLabel->left; pCurrentLabel->X_Position = xPosition; pCurrentLabel->Y_Position = yPosition; if (szLabelText) strcpy(pCurrentLabel->szLabelText , szLabelText); pCurrentLabel->label_type = label_type; pReferenceLabel = &pData->Labels; if ( pReferenceLabel->controlID ) do { if ( pCurrentLabel != pReferenceLabel ) { if ( marge_protection( &derection , pCurrentLabel , pReferenceLabel , iStop_X )) { SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_LEFT , pCurrentLabel->left ); SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_LABEL_TOP , pCurrentLabel->top ); // chack again pReferenceLabel = &pData->Labels; } } pReferenceLabel = pReferenceLabel->pNextLabel; } while(pReferenceLabel); SetCtrlAttribute ( pData->panel , pCurrentLabel->controlID , ATTR_VISIBLE , 1 ); ProcessDrawEvents(); Error: SetBreakOnLibraryErrors (1); return StdError; }