|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
// menubar5.cpp : 定义 DLL 的初始化例程。
//
#include "stdafx.h"
#include "ProToolkit.h"
#include "user_tk_error.h"
#include "pro_wchar_t.h"
#include "ProMdl.h"
#include "ProMenu.h"
#include "ProMenuBar.h"
#include "ProMessage.h"
#include "ProNotify.h"
#include "ProObjects.h"
#include "ProUtil.h"
#include "ProUIDialog.h"
#include "ProUIMessage.h"
#include "ProUIPushbutton.h"
#include "ProSolid.h"
#include "ProWindows.h"
#include "ProFamtable.h"
#include "ProFaminstance.h"
#include "ProUICmd.h"
#include "TestError.h"
#include "ProParamval.h"
/*----------------------------------------------------------------------------*\
Application data types
\*----------------------------------------------------------------------------*/
extern "C"typedef struct user_command
{
char *name;
uiCmdCmdId id;
} UserCommand;
extern "C"typedef struct user_check_but
{
uiCmdCmdId command;
ProBoolean state;
} UserCheckBut;
/*----------------------------------------------------------------------------*\
Application global/external data
\*----------------------------------------------------------------------------*/
extern "C"static wchar_t msgfil[] =
{ 'm','e','n','u','b','a','r','_','m','s','g','.','t','x','t','\0'};
extern "C"static UserCheckBut check_but[2];
extern "C"static uiCmdAccessState access_state = ACCESS_AVAILABLE;
extern "C"static FILE *log_file = NULL;
extern "C"static UserCommand user_actions[] = {
{"TestCheckButtonOpt1", (uiCmdCmdId)NULL},
{"TestCheckButtonOpt2", (uiCmdCmdId)NULL},
{"TestRadioGroupOpt", (uiCmdCmdId)NULL}};
/*====================================================================*\
FUNCTION : ProTestAccessFunction()
PURPOSE : Enable access
\*====================================================================*/
extern "C"static uiCmdAccessState ProTestAccessFunction(uiCmdAccessMode access_mode)
{
return (ACCESS_AVAILABLE);
}
/*====================================================================*\
FUNCTION : ProTestRadioButtonValue()
PURPOSE : Set value for radio group
\*====================================================================*/
extern "C"int ProTestRadioButtonValue(
uiCmdCmdId command,
uiCmdValue *p_value)
{
ProError err;
ProMenuItemName name;
#if 0
err = ProMenubarMenuRadiogrpValueGet (p_value, name);
err = ProMenubarMenuRadiogrpValueSet(p_value, name);
#endif
return (0);
}
/*====================================================================*\
FUNCTION : ProTestRadioButton()
PURPOSE : Callback functions for radio group options
\*====================================================================*/
extern "C"int ProTestRadioButton(
uiCmdCmdId command,
uiCmdValue *p_value)
{
ProError err;
ProMenuItemName name;
err = ProMenubarMenuRadiogrpValueGet (p_value, name);
return(0);
}
/*====================================================================*\
FUNCTION : ProTestCheckButtonValue()
PURPOSE : Set new value for check buttons
\*====================================================================*/
extern "C"int ProTestCheckButtonValue(
uiCmdCmdId command,
uiCmdValue *p_value)
{
ProError err;
ProBoolean bool;
int i;
for (i=0; i<sizeof(check_but)/sizeof(check_but[0]); i++)
if (check_but[i].command == command)
{
err = ProMenubarmenuChkbuttonValueGet (p_value, &bool);
if (bool == check_but[i].state)
continue;
err = ProMenubarmenuChkbuttonValueSet(p_value, check_but[i].state);
break;
}
return(0);
}
/*====================================================================*\
FUNCTION : ProTestCheckButton()
PURPOSE : Callback function for check button options
\*====================================================================*/
extern "C"int ProTestCheckButton(
uiCmdCmdId command,
uiCmdValue *p_value,
void *p_push_command_data)
{
int i;
ProMessageDisplay(msgfil, "TEST Check Button pressed.");
for (i=0; i<sizeof(check_but)/sizeof(check_but[0]); i++)
if (check_but[i].command == command)
{
/* Change state of pressed button */
check_but[i].state = !check_but[i].state;
break;
}
return(0);
}
/*============================================================================*\
Function : ProTestMenuBar
Purpose : Create a menu to test Menu Bar functions
\*============================================================================*/
extern "C"int ProTestMenuBar()
{
ProError err;
uiCmdCmdId push_act, push_act2, action;
uiCmdCmdId radio_act;
int i;
static ProMenuItemName radio_group_items[]=
{"TestRadio1", "TestRadio2", "TestRadio3", ""};
static ProMenuItemLabel radio_group_labels[]=
{"Radio button 1", "Radio button 2", "Radio button 3", ""};
static ProMenuLineHelp radio_group_help[]=
{"Test radio button", "Test radio button", "Test radio button", ""};
/*---------------------------------------------------------------------*\
Add new button to the menu bar
\*---------------------------------------------------------------------*/
err = ProMenubarMenuAdd( "TestMenuBar", "-MenuBar", "Help", PRO_B_FALSE,
msgfil);
err = ProCmdOptionAdd("TestCheckButtonOpt1",
(uiCmdCmdActFn)ProTestCheckButton, PRO_B_TRUE,
(uiCmdCmdValFn)ProTestCheckButtonValue,
ProTestAccessFunction, PRO_B_TRUE, PRO_B_TRUE, &check_but[0].command);
err = ProCmdOptionAdd("TestCheckButtonOpt2",
(uiCmdCmdActFn)ProTestCheckButton, PRO_B_TRUE,
(uiCmdCmdValFn)ProTestCheckButtonValue,
ProTestAccessFunction, PRO_B_TRUE, PRO_B_TRUE, &check_but[1].command);
err = ProCmdOptionAdd("TestRadioGroupOpt",
(uiCmdCmdActFn)ProTestRadioButton, PRO_B_FALSE,
(uiCmdCmdValFn)ProTestRadioButtonValue,
ProTestAccessFunction, PRO_B_TRUE, PRO_B_TRUE, &radio_act);
err = ProMenubarmenuChkbuttonAdd("TestMenuBar", "TestChkBut1",
"Check button 1",
"Test check button 1",NULL, PRO_B_TRUE, check_but[0].command,
msgfil);
err = ProMenubarmenuChkbuttonAdd("TestMenuBar", "TestChkBut2", "Check button 2",
"Test check button 2", "TestChkBut1", PRO_B_TRUE, check_but[1].command,
msgfil);
err = ProMenubarmenuRadiogrpAdd("TestMenuBar", "TestRadioGrp1",
3, radio_group_items, radio_group_labels, radio_group_help,
"TestChkBut2", PRO_B_TRUE, radio_act, msgfil);
return(0);
}
extern "C"int user_initialize()
{
ProTestMenuBar();
return 0;
}
/*---------------------------------------------------------------------------*\
End the Pro/TOOLKIT application
\*---------------------------------------------------------------------------*/
extern "C"void user_terminate()
{
return;
} |
|