既然是Preview,那当然是有一些功能是计划内但是还没有做的。已经完成的控件如下:
PushButton
Check
Option
SplitButton
InfoButton
ComboBox
EditControl
ImageList
ListBox
ListView
ProgressBar
ScrollBar
StaticControl
StatusBar
Tab
TrackBar
TreeView
这个列表距离计划中的1.0版还是有一点差距的,目前尚未完成的功能还有ShowModal、TabIndex、Docking以及Drag and Drop。
为了展示Vczh Library++2.0中GUI Framework的强大威力,我制作了一个Regular Expression Debugger。这个软件可以用来调试正则表达式,主要用于检查正则表达式语法、观察表达式的语法树以及各种状态机、还有匹配测试等。这个Demo已经接近完成。GUI Framework和Demo的代码将在Demo彻底完成的时候放上来。下面贴图和创建界面的代码:
新的尚未最终决定的Placement接口可以轻松实现控件位置的自动调整功能。
void InitControls()
{
/*初始化控件*/
txtRegex=new VL_WinEdit(this,false);
cbRegex=new VL_WinComboBox(this,true);
cbRegex->AddString(L"纯正则表达式");
cbRegex->AddString(L"扩展正则表达式");
cbRegex->AddString(L"贪婪正则表达式");
cbRegex->SetSelectedIndex(2);
lbErrorMessage=new VL_WinStatic(this);
btnGo=new VL_WinButton(this);
btnGo->SetText(L"分析");
tvSyntaxTree=new VL_WinTreeView(this);
tabDebugger=new VL_WinTab(this);
{
/*初始化信息页*/
VL_WinTabPage Page=tabDebugger->AddPage(L"信息");
lbInfo=new VL_WinStatic(Page);
lbInfo->SetText(L"信息内容:");
cbInfo=new VL_WinComboBox(Page,true);
cbInfo->AddString(L"节点详细信息");
cbInfo->AddString(L"语法树");
cbInfo->AddString(L"ε-NFA");
cbInfo->AddString(L"NFA");
cbInfo->AddString(L"DFA");
cbInfo->SetSelectedIndex(0);
txtInfo=new VL_WinEdit(Page,true);
txtInfo->SetHScroll(true);
txtInfo->SetVScroll(true);
txtInfo->SetReadonly(true);
/*设置信息页空间排版*/
Page.ApplyPlacement(
pHorzFix1(10,10,
pVertFix1(0,10,
pControl(lbInfo,60,20),
pVertFix1(0,10,
pControl(cbInfo,120,20),
pBlank(0,0)
)
),
pControl(txtInfo)
)
);
}
{
VL_WinTabPage Page=tabDebugger->AddPage(L"匹配");
cbMatchMethod=new VL_WinComboBox(Page,true);
cbMatchMethod->AddString(L"匹配第一处");
cbMatchMethod->AddString(L"匹配字符串开头");
cbMatchMethod->AddString(L"匹配整个字符串");
cbMatchMethod->AddString(L"搜索所有匹配");
cbMatchMethod->AddString(L"分离字符串");
cbMatchMethod->AddString(L"切割字符串");
cbMatchMethod->SetSelectedIndex(3);
chkMultiline=new VL_WinCheck(Page);
chkMultiline->SetText(L"多行匹配");
chkKeepEmptyPart=new VL_WinCheck(Page);
chkKeepEmptyPart->SetText(L"保留空白切割");
btnMatch=new VL_WinButton(Page);
btnMatch->SetText(L"匹配");
txtMatchInput=new VL_WinEdit(Page,true,true);
txtMatchInput->SetHScroll(true);
txtMatchInput->SetVScroll(true);
txtMatchInput->SetText(L"在这里输入被匹配的字符串。");
txtMatchOutput=new VL_WinEdit(Page,true);
txtMatchOutput->SetHScroll(true);
txtMatchOutput->SetVScroll(true);
txtMatchOutput->SetReadonly(true);
tvMatchStructure=new VL_WinTreeView(Page);
Page.ApplyPlacement(
pHorzFix1(10,10,
pVertFix1(0,10,
pVertFix1(0,10,
pVertFix1(0,10,
pControl(chkMultiline,70,20),
pControl(chkKeepEmptyPart,100,20)
),
pVertFix1(0,10,
pControl(cbMatchMethod,100,20),
pControl(btnMatch,40,20)
)
),
pBlank(0,0)
),
pHorzScale(0,10,0.4,
pControl(txtMatchInput),
pVertScale(0,10,0.4,
pControl(tvMatchStructure),
pControl(txtMatchOutput)
)
)
)
);
}
stStatus=new VL_WinStatus(this);
stStatus->AddItem().SetWidth(200);
stStatus->AddItem().SetWidth(50);
stStatus->AddItem().SetTextRight(L"开发者:陈梓瀚(vczh) http://www.cppblog.com/vczh ");
/*设置控件排版,在窗口尺寸修改的时候自动调整控件尺寸*/
ApplyPlacement(
pHorzFix2(0,0,
pHorzFix1(10,10,
pVertFix1(0,10,
pControl(cbRegex,120,20),
pVertFix2(0,10,
pControl(txtRegex),
pControl(btnGo,40,20)
)
),
pHorzFix1(0,10,
pControl(lbErrorMessage,0,20),
pVertFix1(0,10,
pControl(tvSyntaxTree,300,300),
pControl(tabDebugger,400,300)
)
)
),
pControl(stStatus,0,20)
)
);
/*设置控件事件*/
cbRegex->OnSelChanged.Bind(this,&RegForm::cbRegex_OnSelChanged);
txtRegex->OnChanged.Bind(this,&RegForm::txtRegex_OnChanged);
txtRegex->OnKeyDown.Bind(this,&RegForm::txtRegex_OnKeyDown);
btnGo->OnClick.Bind(this,&RegForm::btnGo_OnClick);
tvSyntaxTree->OnItemSelected.Bind(this,&RegForm::tvSyntaxTree_OnItemSelected);
cbInfo->OnSelChanged.Bind(this,&RegForm::cbInfo_OnSelChanged);
cbMatchMethod->OnSelChanged.Bind(this,&RegForm::cbMatchMethod_OnSelChanged);
btnMatch->OnClick.Bind(this,&RegForm::btnMatch_OnClick);
tvMatchStructure->OnItemSelected.Bind(this,&RegForm::tvMatchStructure_OnItemSelected);
}