q_radiogroup.cpp

来自「QCurses全部代码 QCurses全部代码」· C++ 代码 · 共 90 行

CPP
90
字号
#include   "qcurses/Q_RadioGroup.hpp"/*######################################### 函数功能:构造函数                     ## 函数参数:WINDOW   *vMainWin  主窗口   ##           int      vHigth     高度     ##           int      vWidth     宽度     ##           int      vYBegin    起始y    ##           int      vXBegin    起始x    ##           int      vCFront    文字颜色 ##           int      vCBack     背景色   ##           Q_Items& vItemList  列表项   ##           bool     vMuselect  是否多选 #########################################*/Q_RadioGroup::Q_RadioGroup(WINDOW   *vMainWin,int  vHigth,int  vWidth,int  vYBegin,int  vXBegin,int  vCFront,int  vCBack,Q_Items&  vItemList,bool  vMuselect):Q_Object(vMainWin,  vHigth,  vWidth,  vYBegin,  vXBegin,   true,  vCFront,  vCBack){	Items = vItemList;	Muselect = vMuselect;	NowSelect = 0;	NowKey = 0;	//开始建立列表	for (int i=0;i<Items.size();i++)	{		if (i>RealMaxy-1)			break;		RadioButton[i] = new Q_RadioButton(WorkWin,vWidth-4,1+i,2,vCFront,vCBack);		RadioButton[i]->Set("%s",Items[i].c_str());	}}//------------------------------------------------------------------------------------------/*######################################### 函数功能:控件获取值                   ## 返 回 值:返回的是最后的键盘值         ## 函数参数:NULL                         #########################################*/int      Q_RadioGroup::Get(){	int i=NowSelect,CH=0;	wrefresh(WorkWin);	for (; ; )	{		if (i<0 || i>RealMaxy-1)			i=0;		if (i>=Items.size())			i = Items.size();		if (SelectedNumb()!=-1 && !Muselect)			i = SelectedNumb();		NowKey=RadioButton[i]->Get();		NowSelect = i;		if (NowKey==9 || NowKey==KEY_LEFT || NowKey==KEY_RIGHT)   //Tab			break;		if (RadioButton[i]->Value && !Muselect)			break;				if(NowKey==KEY_UP)			i--;		if(NowKey==KEY_DOWN)			i++;	}	return NowKey;}//------------------------------------------------------------------------------------------/*######################################### 函数功能:如果是单选,返回单选过的下标 ## 返 回 值:是否已经选择                 ## 函数参数:NULL                         #########################################*/int    Q_RadioGroup::SelectedNumb(){	for (int i=0;i<Items.size();i++)		if (RadioButton[i]->Value)			return i;	return -1;}//------------------------------------------------------------------------------------------/*######################################### 函数功能:析构函数                     ## 返 回 值:NULL                         ## 函数参数:NULL                         #########################################*/Q_RadioGroup::~Q_RadioGroup(){	for (int i=0;i<Items.size();i++)		delete RadioButton[i];}

⌨️ 快捷键说明

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