#include "sshWidget.h"
void *eventFilterThread(void *param);
IWidget::IWidget(int x, int y, int w, int h) :
IObject(x ,y ,w ,h),
m_pMenu(NULL),
m_pForm(NULL),
isActive(true),
m_pWindow(NULL),
m_nMenuIndex(PAGE_MENU)
{
PRINTF("width = %d, height = %d", w, h);
m_pWindow = newwin(h, w, y, x);
/* 0, 0 是字符默认的行列起始位置*/
box(m_pWindow, 0 , 0);
keypad(m_pWindow,TRUE);
PRINTF("IWidget() finish");
// pthread_create(&_pThread,NULL,eventFilterThread,(void *)this);
}
IWidget::~IWidget()
{
isActive = false;
if(m_pWindow != NULL)
close();
wborder(m_pWindow, ' ', ' ', ' ',' ',' ',' ',' ',' ');
wrefresh(m_pWindow);
delwin(m_pWindow);
m_pWindow = NULL;
}
void IWidget::setText(const char* str)
{
mvwprintw(m_pWindow, getHeight()/2, getWidth()/2 - strlen(str)/2, str);
}
void IWidget::show()
{
/*刷新窗口缓冲,显示box */
wrefresh(m_pWindow);
}
void IWidget::close()
{
if(m_pMenu != NULL)
{
PRINTF("close Menu!");
delete m_pMenu;
m_pMenu = NULL;
}
if(m_pForm != NULL)
{
PRINTF("close Form!");
delete m_pForm;
m_pForm = NULL;
}
}
void IWidget::eventFilter(int value)
{
if(m_pMenu != NULL)
{
m_pMenu->eventFilter(value);
}
if(m_pForm != NULL)
{
m_pForm->eventFilter(value);
}
}
void IWidget::setCurrentPage(int index)
{
close();
switch(index)
{
case PAGE_MENU:
{
initPageMenu();
break;
}
case PAGE_DEVICE:
{
initPageDev();
break;
}
case PAGE_COMM:
{
initPageComm();
break;
}
case PAGE_VPN:
{
initPageVpn();
break;
}
case PAGE_SNMP:
{
initPageSnmp();
break;
}
case PAGE_DHCP:
{
initPageDhcp();
break;
}
case PAGE_NTP:
{
initPageNtp();
break;
}
default:
break;
}
show();
}
void IWidget::initSelectMenu()
{
m_pMenu = new IMenu(2);
m_pMenu->addItem("Select");
m_pMenu->addItem("Exit");
m_pMenu->setMenuFormat(1, 2);
m_pMenu->show(m_pWindow, 4, 1, 60, 1);
m_nMenuIndex = PAGE_SELECT;
}
void IWidget::initPageMenu()
{
PRINTF("Menu PAGE");
m_pMenu = new IMenu(6);
m_pMenu->addItem("Device Info");
m_pMenu->addItem("Communication");
m_pMenu->addItem("VPN Service");
m_pMenu->addItem("SNMP Service");
m_pMenu->addItem("DHCP Service");
m_pMenu->addItem("NTP Service");
m_pMenu->setMenuFormat(6, 1);
m_pMenu->show(m_pWindow, 4, 5, 40, 6);
PRINTF("Menu PAGE END!");
m_nMenuIndex = PAGE_MENU;
}
void IWidget::initPageDev()
{
PRINTF("DEV PAGE");
m_pForm = new IForm(3);
m_pForm->addForm("VPN Address:", 1, TO_LEFT);
m_pForm->addForm("VPN Subnet:", 3, TO_LEFT);
m_pForm->addForm("Pre-Shared:", 5, TO_LEFT);
m_pForm->show(m_pWindow);
PRINTF("DEV PAGE END!");
m_nMenuIndex = PAGE_DEVICE;
}
void IWidget::initPageComm()
{
PRINTF("COMM PAGE");
m_pForm = new IForm(7);
m_pForm->addForm("Master IP:", 1, TO_LEFT);
m_pForm->addForm("Master Port:", 3, TO_LEFT);
m_pForm->addForm("Slave IP:", 5, TO_LEFT);
m_pForm->addForm("Slave Port:", 7, TO_LEFT);
m_pForm->addForm("APN:", 9, TO_LEFT);
m_pForm->addForm("PPP User:", 11, TO_LEFT);
m_pForm->addForm("ppp Pass:", 13, TO_LEFT);
m_pForm->show(m_pWindow);
PRINTF("COMM PAGE END!");
m_nMenuIndex = PAGE_COMM;
}
void IWidget::initPageVpn()
{
PRINTF("VPN PAGE");
m_pForm = new IForm(3);
m_pForm->addForm("VPN Address:", 1, TO_LEFT);
m_pForm->addForm("VPN Subnet:", 3, TO_LEFT);
m_pForm->addForm("Pre-Shared:", 5, TO_LEFT);
m_pForm->show(m_pWindow);
PRINTF("VPN PAGE END!");
m_nMenuIndex = PAGE_VPN;
}
void IWidget::initPageSnmp()
{
PRINTF("SNMP PAGE");
m_pForm = new IForm(3);
m_pForm->addForm("V3 SNMP User:", 1, TO_LEFT);
m_pForm->addForm("V3 Password:", 3, TO_LEFT);
m_pForm->addForm("V3 DES Key:", 5, TO_LEFT);
m_pForm->show(m_pWindow);
PRINTF("SNMP PAGE END!");
m_nMenuIndex = PAGE_SNMP;
}
void IWidget::initPageDhcp()
{
PRINTF("DHCP PAGE");
m_pForm = new IForm(3);
m_pForm->addForm("DCU IP :", 1, TO_LEFT);
m_pForm->addForm("DCU Mask:", 3, TO_LEFT);
m_pForm->addForm("DCU Gateway:", 5, TO_LEFT);
m_pForm->show(m_pWindow);
PRINTF("DHCP PAGE END!");
m_nMenuIndex = PAGE_DHCP;
}
void IWidget::initPageNtp()
{
m_pForm = new IForm(1);
m_pForm->addForm("NTP Server :", 0, TO_LEFT);
m_pForm->show(m_pWindow);
m_nMenuIndex = PAGE_NTP;
}
没有合适的资源?快使用搜索试试~ 我知道了~
ncurses界面实例
共12个文件
cpp:6个
h:5个
makefile:1个
4星 · 超过85%的资源 需积分: 45 49 下载量 192 浏览量
2017-12-22
15:06:14
上传
评论
收藏 8KB RAR 举报
温馨提示
使用ncurses库编写的类menuconfig的图形界面,有菜单和表单,可以用来简单的显示和修改参数
资源推荐
资源详情
资源评论
收起资源包目录
ncurses.rar (12个子文件)
ncurses
sshObject.cpp 1011B
sshMenu.cpp 2KB
sshObject.h 887B
sshWindow.h 532B
sshWidget.cpp 4KB
sshForm.cpp 2KB
sshMenu.h 766B
sshWindow.cpp 2KB
sshWidget.h 1KB
main.cpp 918B
Makefile 1KB
sshForm.h 577B
共 12 条
- 1
资源评论
- weixin_420494212019-04-25还行,可以参考
- leuelcey2020-06-13研究研究,感谢分享!
Creator_莫言
- 粉丝: 51
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功