📄 uguilistimplement.c
字号:
/*===========================================================================*\FILE : UgUIListImplement.cPURPOSE: UI List - demo & ProTest HISTORY:DATE AUTHOR MODIFICATIONS04-04-01 J-01-31 KB $$1 Created\*===========================================================================*/#include <ProToolkit.h>#include <ProDrawing.h>#include <ProMessage.h>#include <ProMdl.h>#include <ProModelitem.h>#include <ProWindows.h>#include <ProDwgtable.h>#include <ProUtil.h>#include <ProUIDialog.h>#include <ProUIList.h>#include <ProUIPushbutton.h>#include <ProUITextarea.h>#include "UtilString.h"#include "UtilFiles.h"#include "TestError.h"#include "UtilNames.h"#define OK 1#define CANCEL 0void list_OKAction(char *dialog, char *component, ProAppData data);void list_CancelAction(char *dialog, char *component, ProAppData data);ProError UserUIListImplement ();/*==================================================================*\ FUNCTION : list_OKAction() PURPOSE : Action function for the "OK" button\*==================================================================*/void list_OKAction(char *dialog, char *component, ProAppData data){ ProError status; status = ProUIDialogExit(dialog, OK); TEST_CALL_REPORT ("ProUIDialogExit()", "list_OKAction()", status, status!=PRO_TK_NO_ERROR);}/*==================================================================*\ FUNCTION : list_CancelAction() PURPOSE : Action function for the "Cancel" button\*==================================================================*/void list_CancelAction(char *dialog, char *component, ProAppData data){ ProError status; status = ProUIDialogExit(dialog, CANCEL); TEST_CALL_REPORT ("ProUIDialogExit()", "list_CancelAction()", status, status!=PRO_TK_NO_ERROR);}/*===========================================================================*\ FUNCTION: UserUIListImplement PURPOSE: demonstrates how to use the UI ListNames and ListLabel Set functions\*===========================================================================*/ProError UserUIListImplement (){ ProError status; ProDrawing drawing; ProSolid *solids; ProLine wline; wchar_t **model_names; int i, exit_status, num; char **strings, type; char *list_dialog = "ug_uilist"; char *list_comp = "ug_uilist_comp"; char *list_txtarea = "ug_uilist_txtarea"; char *list_pbok = "ug_uilist_ok"; char *list_pbcancel = "ug_uilist_cancel"; /*-------------------------------------------------*\ Get current drawing \*-------------------------------------------------*/ status = ProMdlCurrentGet ((ProMdl*)&drawing); TEST_CALL_REPORT ("ProMdlCurrentGet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); /*-------------------------------------------------*\ Get the models that make the drawing \*-------------------------------------------------*/ status = ProDrawingSolidsCollect(drawing, &solids); TEST_CALL_REPORT ("ProDrawingTablesCollect()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); /*-------------------------------------------------*\ Allocate memory for the char and wchar string arrays \*-------------------------------------------------*/ if (status == PRO_TK_NO_ERROR) { status = ProArraySizeGet ((ProArray)solids, &num); TEST_CALL_REPORT ("ProArraySizeGet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); status = ProArrayAlloc (num, sizeof(wchar_t *), 1, (ProArray *)&model_names); TEST_CALL_REPORT ("ProArrayAlloc()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); status = ProArrayAlloc(num, sizeof(char *), 1, (ProArray *)&strings); TEST_CALL_REPORT ("ProArrayAlloc()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); /*-------------------------------------------------*\ Allocate memory for the char and wchar strings \*-------------------------------------------------*/ for (i=0; i<num; i++) { model_names[i] = (wchar_t *)calloc(PRO_NAME_SIZE, sizeof(wchar_t)); strings[i] = (char *)calloc(PRO_NAME_SIZE, sizeof(char)); /*-------------------------------------------------*\ Get the names of the models that makeup the drawing \*-------------------------------------------------*/ status = ProMdlNameGet ((ProMdl)solids[i], model_names[i]); TEST_CALL_REPORT ("ProMdlNameGet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); /*-------------------------------------------------*\ convert widestrings to strings \*-------------------------------------------------*/ ProWstringToString(strings[i], model_names[i]); } /*-------------------------------------------------*\ Create and set the pushbutton activate actions \*-------------------------------------------------*/ status = ProUIDialogCreate (list_dialog, list_dialog); TEST_CALL_REPORT ("ProUIDialogCreate()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); status = ProUIPushbuttonActivateActionSet (list_dialog, list_pbok, list_OKAction, NULL); TEST_CALL_REPORT ("ProUIPushbuttonActivateSet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); status = ProUIPushbuttonActivateActionSet (list_dialog, list_pbcancel, list_CancelAction, NULL); TEST_CALL_REPORT ("ProUIPushbuttonActivateSet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); /*-------------------------------------------------*\ Populate the list with the model names after activating the dialog and destroy the dialog when done \*-------------------------------------------------*/ status = ProUIListNamesSet (list_dialog, list_comp, num, strings); TEST_CALL_REPORT ("ProUIListNamesSet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); status = ProUIListLabelsSet (list_dialog, list_comp, num, model_names); TEST_CALL_REPORT ("ProUIListLabelsSet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); ProStringToWstring(wline, "These are the names of the parts\nthat makeup the drawing"); status = ProUITextareaValueSet(list_dialog, list_txtarea, wline); TEST_CALL_REPORT ("ProUIListLabelsSet()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); status = ProUIDialogActivate (list_dialog, &exit_status); TEST_CALL_REPORT ("ProUIDialogActivate()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); status = ProUIDialogDestroy (list_dialog); TEST_CALL_REPORT ("ProUIDialogDestroy()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR ); /*-------------------------------------------------*\ Free memory \*-------------------------------------------------*/ status = ProArrayFree ((ProArray*)&solids); TEST_CALL_REPORT ("ProArrayFree()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); status = ProArrayFree((ProArray *)&model_names); TEST_CALL_REPORT ("ProWstringproarrayFree()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); status = ProArrayFree((ProArray *)&strings); TEST_CALL_REPORT ("ProStringproarrayFree()", "UserUIListImplement()", status, status!=PRO_TK_NO_ERROR); } return(PRO_TK_NO_ERROR);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -