Version 3 (modified by 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.
- 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.
- 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
- 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 }
Note:
See TracWiki
for help on using the wiki.