既然是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.shnenglu.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);
}
posted on 2008-08-23 23:18
陳梓瀚(vczh) 閱讀(2096)
評論(6) 編輯 收藏 引用 所屬分類:
C++