wiki:Docs/825gen2/Dev/UpdatingLegacyAppsToNewLook

Version 5 (modified by Don Wilson, 10 months ago) ( diff )

--

Updating Legacy Apps to New Look

Consider if the app to be changed only has minor changes from one of the standard apps. In this case it may be easier to use the code from the new style standard app and merge the changes into it.

Otherwise, the follow the below steps.

  1. Copy the files apphelpers.cpp, apphelpers.h, and appinfo.h from one of the new standard projects such as ID storage into the project to update.
  2. Copy code for main screen features such as below:
    #if ARM64
    
    #define NUM_WT_INDEXES	3 // Gross, tare, net
    #define WT_INDEX_GROSS 	0
    #define WT_INDEX_TARE  	1
    #define WT_INDEX_NET	2
    
    CFormRect rectWtLbl[NUM_WT_INDEXES]; // Location for gross, tare, net labels
    CFormRect rectWt[NUM_WT_INDEXES];
    CFormRect rectWtUnits[NUM_WT_INDEXES];
    CFormRect rectWtStatus;
    CFormRect rectCapacity[2]; // If OIML needs two lines
    CFormRect rectErrorMsg;
    CFormRect rectLargeMsg; // Size of all weight rects, used for "WEIGHT ERROR", or "OVER CAPACITY"
    CFormRect rectManTare;
    CFormRect rectBelowButtons;
    CFormRect rectWeightBackground;
    
    void SetupDisplayLocations(void)
    {
    	int n;
    
    	CFormRect rect;
    	CFormAdvanceY advanceY;
    
    	// Weight status below capacity with is fontIndexSmallPrompt,multiplier 1.0 plus fixed DrawBorder  height FONT_HEIGHT + 16
    	rect.SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0, BORDER_BOX_HEIGHT);
    	rect.SetHeightBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0);
    	rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.26, 0.25); // Show above of gross weight value
    
    	rectWtStatus = rect;
    	rectWtStatus.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.0, 0.30);
    	rectWtStatus.SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.7, BORDER_BOX_HEIGHT);
    
    	for(n = 0; n < 2; n++)
    	{
    		if(n == 0)
    		{
    			rectCapacity[n].SetY(BORDER_BOX_HEIGHT);
    		}
    		else
    		{
    			rectCapacity[n].SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), BORDER_BOX_HEIGHT);
    		}
    		rectCapacity[n].SetX(0);
    		rectCapacity[n].SetLeftAndWidthBasedOnDspArea(&dspMain, 0.01, 0.41);
    		rectCapacity[n].SetHeightBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0);
    	}
    
    	advanceY.SetBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.0, 0);
    
    	rect += advanceY;
    
    	rectManTare = rect;
    	rectManTare.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.31, 0.20);
    	rectManTare.SetTopBasedOnFont(formFontSet.GetFont(fontIndexSmallPrompt), 1.7, BORDER_BOX_HEIGHT);
    
    	// Setup weight label, value, and units locations
    	// horizontal coordinates based on display area width
    	// vertical coordinates based on font heights
    	//
    	//  Header
    	// Capacity 1
    	// Capacity 2
    	//
    	//   |- 0% 25% -|- 26% - 51%  -|- 55% 70% -|
    	//
    	//                wt status
    	//    Gross          120000       lb
    	//
    	//    Tare            40000       lb
    	//
    	//    Net             80000       lb
    	//
    	//   Error message
    	//   ----- Buttons -------
    
    	rect.SetHeightBasedOnFont(fontBigLabel, 1.0);
    	// move Y position down to 1/4 of font height.
    	int heightNZ = fontBigLabel.GetFont(0).GetHeight();
    	heightNZ = heightNZ / 2;
    	int heightZ = fontBigLabel.GetFont(1).GetHeight();
    	heightZ = heightZ / 2;
    	advanceY.SetBasedOnFont(fontBigLabel, 1.0);
    	rect.GetRect(0).SetY(rect.GetRect(0).GetY() + heightNZ);
    	rect.GetRect(1).SetY(rect.GetRect(1).GetY() + heightZ);
    
    	for(n = 0; n < NUM_WT_INDEXES; n++)
    	{
    		rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.01, 0.24);
    		rectWtLbl[n] = rect;
    
    		rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.26, 0.25);
    		rectWt[n] = rect;
    
    		rect.SetLeftAndWidthBasedOnDspArea(&dspMain, 0.55, 0.15);
    		rectWtUnits[n] = rect;
    
    		rect += advanceY;
    	}
    
    	// Large message such as "WEIGHT ERROR" upper left is set same as weight label "Gross", lower right is same as net weight units label.
    	rectLargeMsg.SetLocationAndSizeFrom(rectWtLbl[WT_INDEX_GROSS], rectWtUnits[WT_INDEX_NET]);
    
    	rectWeightBackground.SetLocationAndSizeFrom(rectWtLbl[WT_INDEX_GROSS], rectWtLbl[WT_INDEX_GROSS]);
    	rectWeightBackground.SetX(0);
    	rectWeightBackground.SetWidth(dspMain.GetWidth() - 1);
    
    	rect.SetTopBasedOnFont(formFontSetSmall.GetFont(fontIndexPrompt), 12.0);
    	rect.SetHeightBasedOnFont(formFontSetSmall.GetFont(fontIndexPrompt), 1.0);
    	rect.SetX(0);
    	rect.SetWidth((dspMain.GetWidth() / 2) - 1);
    	rectErrorMsg = rect;
    }
    
    #endif
    
    
  1. Modify functions that do display operations such as shown:
void ShowGTN(void) {

#if ARM64
	SetCurColor(COLOR_INFO);
	SetBkColor(nColorWhite);
	fontBigLabel.DisplayText(rectWtLbl[WT_INDEX_GROSS], LANG(STR_GROSS_LABEL));

	if (curScale >= 0 && GetWtMode(curScale) == wtmode_net) {
		fontBigLabel.DisplayText(rectWtLbl[WT_INDEX_TARE], LANG(STR_TARE_LABEL));
		fontBigLabel.DisplayText(rectWtLbl[WT_INDEX_NET], LANG(STR_NET_LABEL));
	}

#else
	SetCurColor(nColorGreen);
	SetBkColor(nColorBlack);
	DisplayText(GROSS_LBL_X, GROSS_WT_Y, LANG(STR_GROSS_LABEL), 0, BIG_FONT);

	if (curScale >= 0 && GetWtMode(curScale) == wtmode_net) {
		DisplayText(TARE_LBL_X, TARE_WT_Y, LANG(STR_TARE_LABEL), 0, BIG_FONT);
		DisplayText(NET_LBL_X, NET_WT_Y, LANG(STR_NET_LABEL), 0, BIG_FONT);
	}
	SetBkColor(nColorBlack);
#endif
}

  1. Search for all menu and inputs forms such as search for "FORM_INIT" make appropriate changes to use new style FORM_ADD_INPUT2 instead of FORM_ADD_INPUT and FORM_ADD_BUTTON2 instead of FORM_ADD_BUTTON such as:
void MenuConfig(void) 
{
#if ARM64
	CFormRect rect;
	CFormButton btnExit;

	FORM_INIT(Menu, EventMenuCfgShow, NULL, NULL, NULL, nFormFlgNone);

	formMenu.SetFontSet(&formFontSet);

	rect.SetLeftAndWidthBasedOnDspArea(formMenu.GetDspArea(), MENU_BTN_LEFT_OFFSET_PERCENT, MENU_BTN_TWO_COLUMN_WIDTH_PERCENT);
	rect.SetTopAndHeightBasedOnFont(formFontSet.GetFont(fontIndexPrompt),
			MENU_BTN_TOP_FONT_HEIGHT_MULTIPLIER, MENU_BTN_HEIGHT_FONT_HEIGHT_MULTIPLIER);

	FORM_ADD_BUTTON2(Menu, Tickets, 	rect, 	LANG(STR_CONFIG_TICKETS_BTN), 		'T', EventMenuTickets, 		FORM_BUTTON_SHADOW);
	rect += buttonAdvanceY;
	FORM_ADD_BUTTON2(Menu, CfgIDs, 		rect, 	LANG(STR_CONFIG_IDS_BTN), 			'I', EventMenuCfgIDs, 		FORM_BUTTON_SHADOW);
	rect += buttonAdvanceY;
	FORM_ADD_BUTTON2(Menu, Scoreboard, 	rect, 	LANG(STR_CONFIG_SCOREBOARD_BTN),	'S', EventMenuScoreboard, 	FORM_BUTTON_SHADOW | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
	rect += buttonAdvanceY;
	FORM_ADD_BUTTON2(Menu, RFID, 		rect, 	LANG(STR_CONFIG_BADGE_BTN),			'F', EventMenuBadge, 		FORM_BUTTON_SHADOW | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
	rect += buttonAdvanceY;

	rect.SetLeftAndWidthBasedOnDspArea(formMenu.GetDspArea(), MENU_BTN_LEFT_OFFSET_PERCENT, 0.68);

	FORM_ADD_BUTTON2(Menu, LocalRemote, rect,	LANG(STR_CONFIG_LOCAL_REMOTE_BTN), 	'R', EventMenuLocalRemote,	FORM_BUTTON_SHADOW | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
	rect += buttonAdvanceY;
	FORM_ADD_BUTTON2(Menu, Mobile, 		rect,	LANG(STR_CONFIG_MOBILE_BTN), 		'R', EventMenuMobile,		FORM_BUTTON_SHADOW | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);

	rect.SetLeftAndWidthBasedOnDspArea(formMenu.GetDspArea(), MENU_BTN_MID_LEFT, MENU_BTN_TWO_COLUMN_WIDTH_PERCENT);
	rect.SetTopAndHeightBasedOnFont(formFontSet.GetFont(fontIndexPrompt),
			MENU_BTN_TOP_FONT_HEIGHT_MULTIPLIER, MENU_BTN_HEIGHT_FONT_HEIGHT_MULTIPLIER);

	FORM_ADD_BUTTON2(Menu, Language, 	rect, 	LANG(STR_CONFIG_LANGUAGE_BTN), 		'L', EventMenuLanguage, 	FORM_BUTTON_SHADOW);
	rect += buttonAdvanceY;
	FORM_ADD_BUTTON2(Menu, WeightAlarm, rect, 	LANG(STR_CONFIG_WEIGHT_ALARM_BTN),	'A', EventMenuWeightAlarm, 	FORM_BUTTON_SHADOW| FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
#if IP_CAMERA_CAPTURE
	rect += buttonAdvanceY;
	FORM_ADD_BUTTON2(Menu, Cameras, rect, 	LANG(STR_CONFIG_CAMERAS_BTN),	'A', EventMenuCameras, 	FORM_BUTTON_SHADOW);
#endif

	AddFormExitButton(formMenu, btnExit);

#else

	FORM_INIT(Menu, EventMenuCfgShow, NULL, NULL, NULL, nFormFlgNone);
	FORM_ADD_BUTTON(Menu, Tickets, 		MENU_COL1_X, 	MENU_ROW1_Y, 	LANG(STR_CONFIG_TICKETS_BTN), 		'T', EventMenuTickets, 		FORM_BUTTON_INVERT);
	FORM_ADD_BUTTON(Menu, CfgIDs, 		MENU_COL1_X, 	MENU_ROW2_Y, 	LANG(STR_CONFIG_IDS_BTN), 			'I', EventMenuCfgIDs, 		FORM_BUTTON_INVERT);
	FORM_ADD_BUTTON(Menu, Scoreboard, 	MENU_COL1_X, 	MENU_ROW3_Y, 	LANG(STR_CONFIG_SCOREBOARD_BTN),	'S', EventMenuScoreboard, 	FORM_BUTTON_INVERT | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
	FORM_ADD_BUTTON(Menu, RFID, 		MENU_COL1_X, 	MENU_ROW4_Y, 	LANG(STR_CONFIG_BADGE_BTN),			'F', EventMenuBadge, 		FORM_BUTTON_INVERT | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
	FORM_ADD_BUTTON(Menu, LocalRemote, 	MENU_COL1_X, 	MENU_ROW5_Y,	LANG(STR_CONFIG_LOCAL_REMOTE_BTN), 	'R', EventMenuLocalRemote,	FORM_BUTTON_INVERT | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
	FORM_ADD_BUTTON(Menu, Mobile, 		MENU_COL1_X, 	MENU_ROW6_Y,	LANG(STR_CONFIG_MOBILE_BTN), 		'R', EventMenuMobile,		FORM_BUTTON_INVERT | FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);

	FORM_ADD_BUTTON(Menu, Language, 	MENU_COL2_X, 	MENU_ROW1_Y, 	LANG(STR_CONFIG_LANGUAGE_BTN), 		'L', EventMenuLanguage, 	FORM_BUTTON_INVERT);
	FORM_ADD_BUTTON(Menu, WeightAlarm, 	MENU_COL2_X, 	MENU_ROW2_Y, 	LANG(STR_CONFIG_WEIGHT_ALARM_BTN),	'A', EventMenuWeightAlarm, 	FORM_BUTTON_INVERT| FORM_OUTLINE_1LINE_WND | FORM_SHOW_EVENT);
	FORM_ADD_BUTTON(Menu, Exit, 		EXIT_BTN_X, 	EXIT_BTN_Y, 	LANG(STR_EXIT_BTN), 				'X', EventExit, 			FORM_BUTTON_INVERT);
#endif
	FORM_SHOW(Menu);
	FORM_RUN(Menu);
	FORM_HIDE(Menu);

}

void IDScreen(void) 
{
#if ARM64
	CFormRect rect, rectInp;

	FORM_INIT(ID, EventIDShow, NULL, NULL, NULL, nFormFlgShowHelp);

	SetupInputFormToUseFontSet(formID, rect, rectInp, LANG(STR_ID_PROMPT));

	FORM_ADD_INPUT2(ID, ID, rect, 	rectInp, LANG(STR_ID_PROMPT) , 10, 0, 0, NULL, id, 0, NULL, LANG(STR_ID_HELP));
#else
	FORM_INIT(ID, EventIDShow, NULL, NULL, NULL, nFormFlgShowHelp);
	FORM_ADD_INPUT(ID, ID, INPUT_ID_X, INPUT_ID_Y, LANG(STR_ID_PROMPT) , 10, 0, 0, NULL, id, 0, NULL, LANG(STR_ID_HELP));
#endif
	FORM_SHOW(ID);
	FORM_RUN(ID);
	FORM_HIDE(ID);
}


Note: See TracWiki for help on using the wiki.