/*
Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/
#include <ProToolkit.h>
#include <ProUIDialog.h>
#include <ProUIPushbutton.h>
#define UGUIVISIBILITY "uguivisibility"
/*====================================================================*\
FUNCTION: UserCloseAction
PURPOSE: Action function for the Close button in this example
\*====================================================================*/
static void UserCloseAction (char* dialog, char* button, ProAppData data)
{
ProUIDialogExit (UGUIVISIBILITY, PRO_TK_NO_ERROR);
}
/*====================================================================*\
FUNCTION: UserVisibilityToggle
PURPOSE: Action function for the "Visible" checkbutton
\*====================================================================*/
static void UserVisibilityToggle (char* dialog, char* button, ProAppData data)
{
ProBoolean checked;
ProUICheckbuttonGetState (UGUIVISIBILITY, "VisibleCheck", &checked);
if (checked)
ProUIPushbuttonShow (UGUIVISIBILITY, "TargetBtn");
else
ProUIPushbuttonHide (UGUIVISIBILITY, "TargetBtn");
}
/*====================================================================*\
FUNCTION: UserSensitivityToggle
PURPOSE: Action function for the "Sensitive" checkbutton
\*====================================================================*/
static void UserSensitivityToggle (char* dialog, char* button, ProAppData data)
{
ProBoolean checked;
ProUICheckbuttonGetState (UGUIVISIBILITY, "SensitiveCheck", &checked);
if (checked)
ProUIPushbuttonEnable (UGUIVISIBILITY, "TargetBtn");
else
ProUIPushbuttonDisable (UGUIVISIBILITY, "TargetBtn");
}
/*====================================================================*\
FUNCTION: UserRelabelAction
PURPOSE: Action function for the "Label" input panel
\*====================================================================*/
static void UserRelabelAction (char* dialog, char* button, ProAppData data)
{
wchar_t* label;
ProUIInputpanelValueGet (UGUIVISIBILITY, "ButtonLabel", &label);
ProUIPushbuttonTextSet (UGUIVISIBILITY, "TargetBtn", label);
ProWstringFree (label);
}
/*====================================================================*\
FUNCTION: UserUIVisibilityExample
PURPOSE: Shows example of using runtime visibility and sensitivity of
components
\*====================================================================*/
int UserUIVisibilityExample ()
{
ProLine wline;
int status;
/*--------------------------------------------------------------------*\
Load the dialog from the resource file
\*--------------------------------------------------------------------*/
ProUIDialogCreate(UGUIVISIBILITY, UGUIVISIBILITY);
/*--------------------------------------------------------------------*\
Set the OK and Cancel button actions
\*--------------------------------------------------------------------*/
ProUIPushbuttonActivateActionSet(UGUIVISIBILITY,"CloseButton",
UserCloseAction, NULL);
ProUICheckbuttonActivateActionSet(UGUIVISIBILITY,"VisibleCheck",UserVisibilityToggle,
NULL);
ProUICheckbuttonActivateActionSet(UGUIVISIBILITY,"SensitiveCheck",UserSensitivityToggle,
NULL);
ProUIInputpanelInputActionSet(UGUIVISIBILITY,"ButtonLabel",UserRelabelAction,
NULL);
/*--------------------------------------------------------------------*\
Display and activate the dialog
\*--------------------------------------------------------------------*/
ProUIDialogActivate(UGUIVISIBILITY, &status);
/*--------------------------------------------------------------------*\
Remove the dialog from memory
\*--------------------------------------------------------------------*/
ProUIDialogDestroy(UGUIVISIBILITY);
return(1);
}