⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uiinbox.cpp

📁 嵌入式系统PDA的流程
💻 CPP
字号:
#include "UIInBox.h"

#include "UI_Button.h"
#include "UI_String.h"
#include "common.h"

#include "UIAssignList.h"
#include "UINotifyList.h"
#include "UIUserInfoList.h"
#include "UITestResList.h"
#include "UIPersonInfoList.h"

#include "DBAssign.h"
#include "DBNotify.h"
#include "DBUserInfo.h"
#include "DBTestResu.h"
#include "DBPersonInfo.h"

enum {
	ID_SJX_BASE		= ID_XXX_BASE + 500,
	ID_BTN_PGD		= ID_SJX_BASE + 1,
	ID_BTN_TZ		= ID_SJX_BASE + 2,
	ID_BTN_YHZL		= ID_SJX_BASE + 3,
	ID_BTN_CSJG		= ID_SJX_BASE + 4,
	ID_BTN_GRXX		= ID_SJX_BASE + 5,

	ID_STRING_TOTAL	= ID_BTN_GRXX + 1,
	ID_STRING_NEW	= ID_STRING_TOTAL + 6,

	NUM_BUTTONS = 5,
	NUM_STRINGS = 12,
	//index of strings in Strings[] (see below)
	INDEX_PGD_TOTAL		= 1,
	INDEX_TZ_TOTAL		= 2,
	INDEX_YHZL_TOTAL	= 3,
	INDEX_CSJG_TOTAL	= 4,
	INDEX_GRXX_TOTAL	= 5,
	INDEX_PGD_NEW		= 7,
	INDEX_TZ_NEW		= 8,
	INDEX_YHZL_NEW		= 9,
	INDEX_CSJG_NEW		= 10,
	INDEX_GRXX_NEW		= 11
  };
const static struct ButtonInitInfo
{
	ObjectID ID;
	SHORT x, y;
	SHORT Width, Height;
	BYTE  Name[10];
}Buttons[] =
{
	{ID_BTN_PGD,	10,	SECTIONUP_HEIGHT + 20,	60,	15,	"派工单"},
	{ID_BTN_TZ,		10,	SECTIONUP_HEIGHT + 37,	60,	15,	"通知"},
	{ID_BTN_YHZL,	10,	SECTIONUP_HEIGHT + 54,	60,	15,	"用户资料"},
	{ID_BTN_CSJG,	10,	SECTIONUP_HEIGHT + 71,	60,	15,	"测试结果"},
	{ID_BTN_GRXX,	10,	SECTIONUP_HEIGHT + 88,	60,	15,	"个人信息"},
};
static struct StringInitInfo
{
	ObjectID ID;
	SHORT x, y;
	SHORT Width, Height;
	BYTE Name[6];
}Strings[] =
{
	{ID_STRING_TOTAL,	80,	SECTIONUP_HEIGHT+2,	30,	15,	"总计"},
	{ID_STRING_TOTAL+1,	80,	SECTIONUP_HEIGHT+20,	30,	15,	""},
	{ID_STRING_TOTAL+2,	80,	SECTIONUP_HEIGHT+37,	30,	15,	""},
	{ID_STRING_TOTAL+3,	80,	SECTIONUP_HEIGHT+54,	30,	15,	""},
	{ID_STRING_TOTAL+4,	80,	SECTIONUP_HEIGHT+71,	30,	15,	""},
	{ID_STRING_TOTAL+5,	80,	SECTIONUP_HEIGHT+88,	30,	15,	""},

	{ID_STRING_NEW,		120,SECTIONUP_HEIGHT+2,		30,	15,	"未读"},
	{ID_STRING_NEW+1,	120,SECTIONUP_HEIGHT+20,	30,	15,	""},
	{ID_STRING_NEW+2,	120,SECTIONUP_HEIGHT+37,	30,	15,	""},
	{ID_STRING_NEW+3,	120,SECTIONUP_HEIGHT+54,	30,	15,	""},
	{ID_STRING_NEW+4,	120,SECTIONUP_HEIGHT+71,	30,	15,	""},
	{ID_STRING_NEW+5,	120,SECTIONUP_HEIGHT+88,	30,	15,	""}
};

UIInBox::UIInBox ()
{
	m_pTitle = "收件箱";
}

//##ModelId=3D6363E10350
BOOLEAN UIInBox::HandleEvent(EvtType* pEvent)
{
	BOOLEAN bHandled = FALSE;
	switch (pEvent->eventType)
	{
	case EVT_CONTROL_SELECT:
		{
			UISectionCenter *pNextSectionCenter = NULL;
			switch (pEvent->eventID)
			{
			case ID_BTN_PGD:
				pNextSectionCenter = new UIAssignList();
				break;
			case ID_BTN_TZ:
				pNextSectionCenter = new UINotifyList();
				break;
			case ID_BTN_YHZL:
				pNextSectionCenter = new UIUserInfoList();
				break;
			case ID_BTN_CSJG:
				pNextSectionCenter = new UITestResList();
				break;
			case ID_BTN_GRXX:
				pNextSectionCenter = new UIPersonInfoList();
				break;
			case ID_MAIN_RETURN:
				OnReturnClick();//derived from UISectionCenter
				bHandled = TRUE;
				break;
			}
			if (NULL != pNextSectionCenter)
			{
				DestroyWindow();
				pNextSectionCenter->Enter(this);
				bHandled = TRUE;
			}
		}
	}
	return bHandled;
}

//##ModelId=3D5080BD036D
SHORT UIInBox::GetAssignTotalCnt()
{
	DBAssign theDBAssign;
	//theDBAssign.OpenTable(EMDB_RDONLY);
	SHORT iTotalCnt = theDBAssign.GetRecCnt();
	//theDBAssign.CloseTable();
	return iTotalCnt;
}

//##ModelId=3D50811A03A3
SHORT UIInBox::GetAssignNewCnt()
{
	DBAssign theDBAssign;
	//theDBAssign.OpenTable(EMDB_RDONLY);
	SHORT iNewCnt = theDBAssign.GetNewCnt();
	//theDBAssign.CloseTable();
	return iNewCnt;
}

//##ModelId=3D50812903A4
SHORT UIInBox::GetNotifyTotalCnt()
{
	DBNotify theDBNotify;
	//theDBNotify.OpenTable(EMDB_RDONLY);
	SHORT iTotalCnt = theDBNotify.GetRecCnt();
	//theDBNotify.CloseTable();
	return iTotalCnt;
}

//##ModelId=3D50813A00D8
SHORT UIInBox::GetNotifyNewCnt()
{
	DBNotify theDBNotify;
	//theDBNotify.OpenTable(EMDB_RDONLY);
	SHORT iNewCnt = theDBNotify.GetNewCnt();
	//theDBNotify.CloseTable();
	return iNewCnt;
}

//##ModelId=3D5081470325
SHORT UIInBox::GetPersonalTotalCnt()
{
	DBPersonInfo theDBPersonInfo;
	//theDBPersonInfo.OpenTable(EMDB_RDONLY);
	SHORT iTotalCnt = theDBPersonInfo.GetRecCnt();
	//theDBPersonInfo.CloseTable();
	return iTotalCnt;
}

//##ModelId=3D5081A8027A
SHORT UIInBox::GetPersonalNewCnt()
{
	DBPersonInfo theDBPersonInfo;
	//theDBPersonInfo.OpenTable(EMDB_RDONLY);
	SHORT iNewCnt = theDBPersonInfo.GetNewCnt();
	//theDBPersonInfo.CloseTable();
	return iNewCnt;
}

//##ModelId=3D5081EA008B
SHORT UIInBox::GetTestTotalCnt()
{
	DBTestResu theDBTest;
	//theDBTest.OpenTable(EMDB_RDONLY);
	SHORT iTotalCnt = theDBTest.GetRecCnt();
	//theDBTest.CloseTable();
	return iTotalCnt;
}

//##ModelId=3D5081A803B1
SHORT UIInBox::GetTestNewCnt()
{
	DBTestResu theDBTest;
	//theDBTest.OpenTable(EMDB_RDONLY);
	SHORT iNewCnt = theDBTest.GetNewCnt();
	//theDBTest.CloseTable();
	return iNewCnt;
}

//##ModelId=3D50832700A4
SHORT UIInBox::GetUserTotalCnt()
{
	DBUserInfo theDBUserInfo;
	//theDBUserInfo.OpenTable(EMDB_RDONLY);
	SHORT iTotalCnt = theDBUserInfo.GetRecCnt();
	//theDBUserInfo.CloseTable();
	return iTotalCnt;
}

//##ModelId=3D5083520092
SHORT UIInBox::GetUserNewCnt()
{
	DBUserInfo theDBUserInfo;
	//theDBUserInfo.OpenTable(EMDB_RDONLY);
	SHORT iNewCnt = theDBUserInfo.GetNewCnt();
	//theDBUserInfo.CloseTable();
	return iNewCnt;
}

//##ModelId=3D625BCE02E7
Err UIInBox::Initialize()
{
	int i;
	//create the buttons in UI
	for (i = 0; i < NUM_BUTTONS; i++)
	{
		UI_ButtonInit2(Buttons[i].ID,
							Buttons[i].x, Buttons[i].y,
							Buttons[i].Height, Buttons[i].Width,
							(BYTE*)(Buttons[i].Name),
							PDAXWT_FORM);//form id

		ControlSetAttributes(Buttons[i].ID,TRUE,FALSE,FALSE,TRUE,TRUE);
	}
	//prepare string names (counts)
	sprintf((char*)Strings[INDEX_PGD_TOTAL].Name, "%d", GetAssignTotalCnt());
	sprintf((char*)Strings[INDEX_PGD_NEW  ].Name, "%d", GetAssignNewCnt());
	sprintf((char*)Strings[INDEX_TZ_TOTAL].Name, "%d", GetNotifyTotalCnt());
	sprintf((char*)Strings[INDEX_TZ_NEW  ].Name, "%d", GetNotifyNewCnt());
	sprintf((char*)Strings[INDEX_YHZL_TOTAL].Name, "%d", GetUserTotalCnt());
	sprintf((char*)Strings[INDEX_YHZL_NEW  ].Name, "%d", GetUserNewCnt());
	sprintf((char*)Strings[INDEX_CSJG_TOTAL].Name, "%d", GetTestTotalCnt());
	sprintf((char*)Strings[INDEX_CSJG_NEW  ].Name, "%d", GetTestNewCnt());
	sprintf((char*)Strings[INDEX_GRXX_TOTAL].Name, "%d", GetPersonalTotalCnt());
	sprintf((char*)Strings[INDEX_GRXX_NEW  ].Name, "%d", GetPersonalNewCnt());
	//create strings
	for (i = 0; i < NUM_STRINGS; i++)
	{
		UI_StringInit(Strings[i].ID,
								Strings[i].x, Strings[i].y,
								Strings[i].Height, Strings[i].Width,
								(BYTE*)(Strings[i].Name),
								PDAXWT_FORM);//form id

		StringSetAttribute(Strings[i].ID,TRUE,TRUE);
	}

	//create return button
	UISectionCenter::CreateUIObjects();

	return SUC;

/*QUIT:
	DestroyWindow();
	return ERR_UI;*/
}

//##ModelId=3D625BAC0324
void UIInBox::Show()
{
	int i;

	for (i = 0; i < NUM_BUTTONS; i++)
	{
		//ControlEraseControl(Buttons[i].ID);
		ControlDrawControl(Buttons[i].ID);
	}
	for (i = 0; i < NUM_STRINGS; i++)
	{
		//StringEraseString(Strings[i].ID);
		StringDrawString(Strings[i].ID);
	}

	//delete return button
	DrawReturnButton();
}

//##ModelId=3D61BE030354
Err UIInBox::DestroyWindow()
{
	int i;

	for (i = 0; i < NUM_BUTTONS; i++)
	{
		//ControlEraseControl(Buttons[i].ID);
		UI_FormDeleteObject(Buttons[i].ID, PDAXWT_FORM);
	}
	for (i = 0; i < NUM_STRINGS; i++)
	{
		//StringEraseString(Strings[i].ID);
		UI_FormDeleteObject(Strings[i].ID, PDAXWT_FORM);
	}

	//delete return button
	UISectionCenter::DestroyUIObjects();

	return SUC;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -