/*
	Copyright (c) 2024 PTC Inc. and/or Its Subsidiary Companies. All Rights Reserved.
*/


#include <ProToolkit.h>
#include <ProMenuBar.h>
#include <ProUICmd.h>
#include <ProNotify.h>


#include <PTUDFExamples.h>
#include <PTApplsUnicodeUtils.h>

static ProFileName  message_file;

/*====================================================================*\
  FUNCTION :   user_initialize()
  PURPOSE  :   Application initialization	
\*====================================================================*/
int user_initialize(int argc, char* argv [])
{
  uiCmdCmdId cmd_id;
  char* no_ui_env = NULL;

  ProStringToWstring (message_file, "pt_udf_ex_menubar.txt" ); 

/*---------------------------------------------------------------------*\
Add the application main menu
\*---------------------------------------------------------------------*/
  status = ProMenubarMenuAdd ("PTUDFExamples", "PTUDFExMenuLabel", "Info",
			      PRO_B_TRUE, message_file );

/*---------------------------------------------------------------------*\
Add the button for UDF placement dashboard
\*---------------------------------------------------------------------*/
  status = ProCmdActionAdd("PTUDFExamples.PlaceUDF", (uiCmdCmdActFn)PTUDFExUDFDashboardMain,
			   uiProeImmediate, PTUDFExAccessPlaceUDF,
			   PRO_B_FALSE, PRO_B_FALSE, &cmd_id);
  
  status = ProMenubarmenuPushbuttonAdd(
				       "PTUDFExamples", "UDFPlace", 
				       "PTUDFExPlaceLabel", 
				       "PTUDFEx Place a UDF using a dashboard",
				       NULL, PRO_B_TRUE, cmd_id, message_file);

/*---------------------------------------------------------------------*\
Add the notification to show & write the parameter data for the library AE
parameters after the library has been created or modified.
\*---------------------------------------------------------------------*/
  status = ProNotificationSet (PRO_UDF_LIB_COMPLETE_POST, PTUDFExPostLibraryEditAction);
  PT_TEST_LOG_SUCC ("ProNotificationSet()");

/*---------------------------------------------------------------------*\
Add the notification to prevent ungrouping.
\*---------------------------------------------------------------------*/
  status = ProNotificationSet (PRO_GROUP_UNGROUP_PRE, PTUDFExUgroupPreventAction);
  PT_TEST_LOG_SUCC ("ProNotificationSet()");

  if (argc > 1)
    {
      if (strcmp (argv [1], "+no_ui") == 0)
	show_ui = PRO_B_FALSE;
    }

  no_ui_env = getenv ("PT_UDF_EX_NO_UI");
  if (no_ui_env != NULL)
    show_ui = PRO_B_FALSE;

  return(0);
}

void user_terminate()
{
}