青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆-341  評(píng)論-2670  文章-0  trackbacks-0
    GacUI在結(jié)束了文本框的介紹之后,開始進(jìn)入列表的介紹。列表內(nèi)容豐富,包含各種預(yù)定義的列表控件、用來顯示和操作大量對(duì)象的虛擬模式、MVC分離、修改列表樣式等內(nèi)容。今天先從文本列表的簡(jiǎn)單操作開始。這個(gè)Demo展示了如何對(duì)列表進(jìn)行添加和刪除。窗口里面有一個(gè)列表,然后有添加和刪除兩個(gè)按鈕,分別用于把文本框的內(nèi)容添加到列表內(nèi),和刪除掉選中的列表項(xiàng)的。在這個(gè)Demo里面只允許列表項(xiàng)單選,并且水平滾動(dòng)條默認(rèn)不出現(xiàn)。先看圖:



    空間如何布局,我就不再贅述了,明顯是一個(gè)四行三列的表格。代碼如下:

#include "..\..\Public\Source\GacUIIncludes.h"
#include 
<Windows.h>

// for SortedList, CopyFrom and Select
using namespace vl::collections;

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
{
    
return SetupWindowsDirect2DRenderer();
}

class NameEditorWindow : public GuiWindow
{
private:
    GuiTextList
*                        listBox;
    GuiSinglelineTextBox
*                textBox;
    GuiButton
*                            buttonAdd;
    GuiButton
*                            buttonRemove;
    
    
void buttonAdd_Clicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        
// add the specified name at the end of the list box
        listBox->GetItems().Add(textBox->GetText());
        textBox
->SelectAll();
        textBox
->SetFocus();
    }

    
void buttonRemove_Clicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        
// remove the selected items using item index
        listBox->GetItems().RemoveAt(listBox->GetSelectedItems()[0]);
    }

    
void listBox_SelectionChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        
// disable the button if no item is selected
        buttonRemove->SetEnabled(listBox->GetSelectedItems().Count()>0);
    }
public:
    NameEditorWindow()
        :GuiWindow(GetCurrentTheme()
->CreateWindowStyle())
    {
        
this->SetText(L"Controls.ListBox.NameEditor");

        GuiTableComposition
* table=new GuiTableComposition;
        table
->SetRowsAndColumns(43);
        table
->SetCellPadding(3);
        table
->SetAlignmentToParent(Margin(0000));

        table
->SetRowOption(0, GuiCellOption::MinSizeOption());
        table
->SetRowOption(1, GuiCellOption::MinSizeOption());
        table
->SetRowOption(2, GuiCellOption::MinSizeOption());
        table
->SetRowOption(3, GuiCellOption::PercentageOption(1.0));

        table
->SetColumnOption(0, GuiCellOption::PercentageOption(1.0));
        table
->SetColumnOption(1, GuiCellOption::MinSizeOption());
        table
->SetColumnOption(2, GuiCellOption::MinSizeOption());

        
this->GetContainerComposition()->AddChild(table);
        
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            cell
->SetSite(0041);

            listBox
=g::NewTextList();
            listBox
->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
            listBox
->SetHorizontalAlwaysVisible(false);
            listBox
->SelectionChanged.AttachMethod(this&NameEditorWindow::listBox_SelectionChanged);
            cell
->AddChild(listBox->GetBoundsComposition());
        }
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            cell
->SetSite(0111);

            GuiLabel
* label=g::NewLabel();
            label
->SetText(L"Name to add: ");
            label
->GetBoundsComposition()->SetAlignmentToParent(Margin(0-100));
            cell
->AddChild(label->GetBoundsComposition());
        }
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            cell
->SetSite(0211);

            textBox
=g::NewTextBox();
            textBox
->GetBoundsComposition()->SetPreferredMinSize(Size(12023));
            textBox
->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
            cell
->AddChild(textBox->GetBoundsComposition());
        }
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            cell
->SetSite(1112);

            buttonAdd
=g::NewButton();
            buttonAdd
->SetText(L"Add");
            buttonAdd
->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
            buttonAdd
->Clicked.AttachMethod(this&NameEditorWindow::buttonAdd_Clicked);
            cell
->AddChild(buttonAdd->GetBoundsComposition());
        }
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            cell
->SetSite(2112);

            buttonRemove
=g::NewButton();
            buttonRemove
->SetText(L"Delete");
            buttonRemove
->SetEnabled(false);
            buttonRemove
->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
            buttonRemove
->Clicked.AttachMethod(this&NameEditorWindow::buttonRemove_Clicked);
            cell
->AddChild(buttonRemove->GetBoundsComposition());
        }

        
// set the preferred minimum client size
        this->GetBoundsComposition()->SetPreferredMinSize(Size(480480));
        
// call this to calculate the size immediately if any indirect content in the table changes
        
// so that the window can calcaulte its correct size before calling the MoveToScreenCenter()
        this->ForceCalculateSizeImmediately();
        
// move to the screen center
        this->MoveToScreenCenter();
    }
};

void GuiMain()
{
    GuiWindow
* window=new NameEditorWindow;
    GetApplication()
->Run(window);
    delete window;
}

    這里需要注意的幾點(diǎn)就是,為了實(shí)現(xiàn)在列表沒有選中內(nèi)容的時(shí)候禁用刪除按鈕,我們需要監(jiān)聽GuiTextList::SelectionChanged事件。核心的代碼就是下面這幾行:

    void buttonAdd_Clicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        
// add the specified name at the end of the list box
        listBox->GetItems().Add(textBox->GetText());
        textBox
->SelectAll();
        textBox
->SetFocus();
    }

    
void buttonRemove_Clicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        
// remove the selected items using item index
        listBox->GetItems().RemoveAt(listBox->GetSelectedItems()[0]);
    }

    
void listBox_SelectionChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        
// disable the button if no item is selected
        buttonRemove->SetEnabled(listBox->GetSelectedItems().Count()>0);
    }

    GuiTextList控件的GetItems函數(shù)返回所有的列表項(xiàng)。這個(gè)對(duì)象有Add、Insert、Clear、IndexOf、Remove、RemoveAt、Contains、Count等函數(shù),可以用來操作列表項(xiàng)。GuiTextList還有GetSelectedItems函數(shù)(其實(shí)是定義在GuiSelectableListControl里面的),可以用來獲得所有選中的列表項(xiàng)的下標(biāo)(從0開始)。每當(dāng)列表內(nèi)容被修改的時(shí)候,GetSelectedItems的結(jié)果就會(huì)被自動(dòng)清空。

    下一個(gè)Demo將是關(guān)于如何處理允許多選的列表的操作方法。
posted on 2012-05-23 04:42 陳梓瀚(vczh) 閱讀(2372) 評(píng)論(4)  編輯 收藏 引用 所屬分類: GacUI

評(píng)論:
# re: GacUI Demo:簡(jiǎn)單文本列表操作 2012-05-23 05:02 | ArthasLee
做完demo準(zhǔn)備作甚?  回復(fù)  更多評(píng)論
  
# re: GacUI Demo:簡(jiǎn)單文本列表操作 2012-05-23 05:57 | 陳梓瀚(vczh)
@ArthasLee
做release  回復(fù)  更多評(píng)論
  
# re: GacUI Demo:簡(jiǎn)單文本列表操作 2012-05-24 00:44 | zrd
gacui可以在linux下使用么?  回復(fù)  更多評(píng)論
  
# re: GacUI Demo:簡(jiǎn)單文本列表操作 2012-05-24 07:19 | 陳梓瀚(vczh)
@zrd
還沒支持linux,得先在windows上把gcc過了再說。不過話說用linux的人不是很待見GUI嗎?  回復(fù)  更多評(píng)論
  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            免费中文日韩| 亚洲一级影院| 亚洲成色www8888| 免费看亚洲片| 亚洲在线中文字幕| 亚洲精品国产精品久久清纯直播| 欧美久久久久久久久久| 亚洲国产日韩一级| 欧美1区2区视频| 欧美一区深夜视频| 亚洲欧美日韩在线不卡| 国产综合欧美| 国产精品麻豆va在线播放| 国产区精品视频| 欧美日韩另类丝袜其他| 性刺激综合网| 一二三区精品| 99综合在线| 亚洲图片你懂的| 亚洲精品乱码久久久久久| 欧美一级播放| 午夜精品在线看| 欧美一区亚洲| 久久久www成人免费无遮挡大片| 国产精品成人久久久久| 欧美成人自拍| 欧美日韩日日夜夜| 国内激情久久| 亚洲欧美日韩精品久久久| 你懂的视频欧美| 亚洲二区在线| 亚洲欧洲日韩在线| 亚洲网站在线看| 亚洲综合国产| 欧美大片免费观看在线观看网站推荐| 欧美成人精品一区| 国产亚洲精品福利| 亚洲免费小视频| 一区二区不卡在线视频 午夜欧美不卡'| 欧美在线观看一二区| 欧美色123| 欧美精品免费视频| 亚洲精品久久嫩草网站秘色| 国产亚洲在线| 久久久久久久久岛国免费| 日韩一区二区精品在线观看| 亚洲人成亚洲人成在线观看图片| 亚洲欧美一区二区三区在线| 久久福利影视| 国产一区二区三区免费在线观看 | 亚洲国产精品精华液网站| 亚洲影院免费观看| 国内成+人亚洲| 亚洲国产网站| 国产综合自拍| 亚洲精品色婷婷福利天堂| 麻豆freexxxx性91精品| 国模一区二区三区| 99在线精品视频在线观看| 欧美日韩在线播放一区| 在线午夜精品自拍| 欧美在线不卡视频| 亚洲小说春色综合另类电影| 亚洲福利视频在线| 国产日韩欧美日韩| 亚洲欧洲精品一区二区| 欧美日韩精品在线观看| 欧美在线一级va免费观看| 一本色道久久综合精品竹菊 | 久久久久国产免费免费| 一区二区不卡在线视频 午夜欧美不卡在 | 六月天综合网| 羞羞漫画18久久大片| 久久久久天天天天| 久久中文精品| 国产综合色在线| 一本久道久久久| 一区二区三区我不卡| 中国女人久久久| 亚洲一区成人| 欧美日韩调教| 亚洲永久免费av| 欧美在线高清| 国产欧美韩日| 影音先锋久久久| 欧美一级久久久久久久大片| 国产女主播一区二区三区| 噜噜噜91成人网| 亚洲九九爱视频| 国产精品久久波多野结衣| 99国产一区二区三精品乱码| 亚洲第一区在线| 欧美日韩亚洲激情| 欧美影院在线| 亚洲国产cao| 99精品久久久| 欧美福利一区二区| 欧美日韩精品在线| 中文久久精品| 免费观看成人鲁鲁鲁鲁鲁视频| 国产精品午夜久久| 欧美成人午夜激情视频| 亚洲一区在线播放| 亚洲国产日韩美| 久久人91精品久久久久久不卡| 伊甸园精品99久久久久久| 日韩视频欧美视频| 久久综合中文| 母乳一区在线观看| 亚洲香蕉在线观看| 亚洲免费视频在线观看| 国产精品一区=区| 中国女人久久久| 性一交一乱一区二区洋洋av| 老司机亚洲精品| 欧美一区成人| 久久人人爽爽爽人久久久| 久久精品伊人| 国产精品久久久久久妇女6080 | 久久成人免费电影| 久久一区二区三区国产精品| 欧美片第一页| 国产亚洲va综合人人澡精品| 亚洲激情综合| 欧美一区二区三区在线免费观看| 久久综合网hezyo| 亚洲美女福利视频网站| 久久九九热re6这里有精品| 欧美日韩国产三区| 亚洲国产精品一区| 欧美成人精品在线播放| 欧美一区二区日韩一区二区| 欧美区亚洲区| 亚洲愉拍自拍另类高清精品| 亚洲国产精品一区| 老司机精品导航| 亚洲高清不卡一区| 欧美激情自拍| 欧美国产精品v| 亚洲一区二区三区免费观看 | 欧美激情视频一区二区三区在线播放| 亚洲国产婷婷香蕉久久久久久99 | 久久久综合网| 午夜精品福利视频| 伊人成人在线| 亚洲伦理在线| 国产欧美日韩综合精品二区| 久久久人人人| 午夜在线电影亚洲一区| 亚洲视频在线二区| 一区二区三区在线视频播放| 欧美成人免费一级人片100| 欧美精品激情在线观看| 亚洲综合色网站| 久久蜜桃av一区精品变态类天堂| 最新69国产成人精品视频免费| 日韩西西人体444www| 一色屋精品亚洲香蕉网站| 亚洲精品自在久久| 国产精品青草综合久久久久99| 久久国产福利国产秒拍| 久久综合伊人77777麻豆| 亚洲无限av看| 欧美96在线丨欧| 久久久国产精品一区二区中文| 免费不卡在线观看| 久久久噜噜噜久久中文字幕色伊伊 | 亚洲天堂第二页| 国产精品综合久久久| 欧美1级日本1级| 欧美调教vk| 亚洲精品欧美日韩专区| 亚洲伦理自拍| 欧美激情2020午夜免费观看| 亚洲综合视频一区| 一本色道久久综合狠狠躁篇的优点| 在线观看欧美一区| 久久综合一区二区| 欧美成人一区在线| 亚洲日本一区二区三区| 免费久久精品视频| 欧美女人交a| 亚洲成人在线视频网站| 一区二区三区在线视频播放| 亚洲欧美激情在线视频| 亚洲无限乱码一二三四麻| 蜜臀av性久久久久蜜臀aⅴ| 两个人的视频www国产精品| 欧美制服丝袜第一页| 国产日韩欧美电影在线观看| 亚欧成人精品| 欧美成人午夜免费视在线看片| 一区精品久久| 欧美日韩视频在线第一区| 亚洲一区二区在线免费观看视频| 午夜精品福利电影| 在线电影一区| 欧美激情区在线播放| 亚洲伊人第一页| 亚洲国产成人av在线 |