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

隨筆-341  評論-2670  文章-0  trackbacks-0
    GacUI在結(jié)束了文本框的介紹之后,開始進(jìn)入列表的介紹。列表內(nèi)容豐富,包含各種預(yù)定義的列表控件、用來顯示和操作大量對象的虛擬模式、MVC分離、修改列表樣式等內(nèi)容。今天先從文本列表的簡單操作開始。這個(gè)Demo展示了如何對列表進(jìn)行添加和刪除。窗口里面有一個(gè)列表,然后有添加和刪除兩個(gè)按鈕,分別用于把文本框的內(nèi)容添加到列表內(nèi),和刪除掉選中的列表項(xiàng)的。在這個(gè)Demo里面只允許列表項(xià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è)對象有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é)果就會被自動清空。

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

評論:
# re: GacUI Demo:簡單文本列表操作 2012-05-23 05:02 | ArthasLee
做完demo準(zhǔn)備作甚?  回復(fù)  更多評論
  
# re: GacUI Demo:簡單文本列表操作 2012-05-23 05:57 | 陳梓瀚(vczh)
@ArthasLee
做release  回復(fù)  更多評論
  
# re: GacUI Demo:簡單文本列表操作 2012-05-24 00:44 | zrd
gacui可以在linux下使用么?  回復(fù)  更多評論
  
# re: GacUI Demo:簡單文本列表操作 2012-05-24 07:19 | 陳梓瀚(vczh)
@zrd
還沒支持linux,得先在windows上把gcc過了再說。不過話說用linux的人不是很待見GUI嗎?  回復(fù)  更多評論
  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲高清二区| 免费观看亚洲视频大全| 久久爱www.| 国内精品久久久久伊人av| 欧美一区二区在线观看| 免费观看国产成人| 亚洲精品国产精品国自产观看浪潮| 欧美成人久久| av成人免费| 久久久久九九九| 亚洲国产精品毛片| 欧美日韩一区二区三区高清| 亚洲一级黄色av| 老司机一区二区三区| 亚洲人成毛片在线播放女女| 欧美色播在线播放| 欧美在线亚洲一区| 亚洲精品123区| 性久久久久久久| 激情婷婷欧美| 欧美日韩妖精视频| 欧美中文字幕| 亚洲乱码国产乱码精品精| 欧美在线三级| 亚洲精品日韩在线观看| 国产精品丝袜xxxxxxx| 麻豆成人av| 亚洲一区自拍| 亚洲高清在线| 久久精品亚洲乱码伦伦中文 | 黑人一区二区| 欧美国产极速在线| 午夜精品一区二区三区在线播放| 欧美国产精品人人做人人爱| 亚洲砖区区免费| 在线观看日韩| 国产欧美激情| 欧美日韩国产成人在线| 欧美专区在线观看一区| 一区二区三区黄色| 欧美激情导航| 久久人人爽国产| 亚洲男人av电影| 亚洲免费观看在线视频| 狠狠色狠狠色综合日日91app| 欧美日韩亚洲高清一区二区| 久久久激情视频| 亚洲综合国产精品| 99国产精品一区| 欧美成人中文| 久久精品夜色噜噜亚洲aⅴ| 亚洲天堂网在线观看| 亚洲欧洲另类| 在线观看成人一级片| 国产欧美精品一区| 国产精品久久一卡二卡| 欧美日韩一区二区三区免费| 欧美 日韩 国产 一区| 欧美在线日韩| 午夜在线精品| 亚洲尤物影院| 亚洲天堂av图片| 日韩视频免费观看高清完整版| 欧美国产综合| 欧美大片国产精品| 欧美xxx在线观看| 麻豆av福利av久久av| 久久久久亚洲综合| 久久久91精品国产| 久久人人97超碰国产公开结果 | 久久久久久久网站| 亚洲欧美在线观看| 羞羞漫画18久久大片| 亚洲欧美在线免费观看| 亚洲欧美日韩精品在线| 亚洲欧美日本视频在线观看| 亚洲图片在线| 亚洲一区影音先锋| 亚洲欧美经典视频| 校园激情久久| 久久精品人人爽| 久久久噜噜噜久噜久久| 久久一区二区三区av| 美女久久网站| 欧美激情亚洲| 日韩一区二区精品葵司在线| av成人免费在线观看| 亚洲少妇中出一区| 午夜精品久久久久久久| 久久久久久久久久久成人| 久久综合伊人77777蜜臀| 欧美jizz19性欧美| 欧美色图天堂网| 国产精品人人爽人人做我的可爱 | 狠狠色狠狠色综合人人| 亚洲国产精品国自产拍av秋霞| 最新日韩av| 亚洲天堂av在线免费观看| 亚洲欧美一区二区激情| 久久久精品性| 亚洲观看高清完整版在线观看| 日韩视频亚洲视频| 午夜精品久久久久久久99樱桃| 久久久久综合一区二区三区| 欧美.日韩.国产.一区.二区| 欧美日本一区二区视频在线观看| 国产精品免费区二区三区观看| 国产综合色产| 99热这里只有精品8| 欧美一区二区三区婷婷月色| 欧美成人免费一级人片100| 亚洲精品一区二| 欧美一区二区免费观在线| 欧美/亚洲一区| 国产九九精品视频| 亚洲精品在线视频观看| 新片速递亚洲合集欧美合集| 欧美激情二区三区| 亚洲一区在线视频| 欧美成人tv| 国产一区二区三区久久精品| 一本久道久久久| 久久亚洲综合网| 艳妇臀荡乳欲伦亚洲一区| 久久精品国产综合精品| 欧美日韩精选| 亚洲国产精品美女| 欧美淫片网站| 一本色道久久| 欧美成人小视频| 国产一区二区电影在线观看 | 久久综合一区二区| 国产精品视频久久| 亚洲精品永久免费精品| 欧美一区二区免费观在线| 亚洲精品之草原avav久久| 久久午夜羞羞影院免费观看| 国产精品日韩欧美综合 | 免费一级欧美在线大片| 亚洲一区二区三区精品在线| 欧美激情精品久久久久久| 极品裸体白嫩激情啪啪国产精品| 亚洲在线免费观看| 亚洲欧洲中文日韩久久av乱码| 久久久91精品国产| 国产欧美日韩伦理| 午夜精品福利一区二区蜜股av| 最新国产の精品合集bt伙计| 久热综合在线亚洲精品| 黄色亚洲免费| 久久精品久久综合| 午夜国产精品视频| 国产精品实拍| 午夜一区二区三视频在线观看| 亚洲人成免费| 欧美女同在线视频| 亚洲精品乱码久久久久久蜜桃91| 欧美成年人网站| 久久精品国产亚洲高清剧情介绍| 国产日本欧美一区二区| 先锋a资源在线看亚洲| 亚洲一区二区三区四区在线观看| 欧美日韩午夜视频在线观看| 99精品免费| 亚洲麻豆av| 欧美日韩免费高清一区色橹橹| av成人动漫| 亚洲每日在线| 欧美揉bbbbb揉bbbbb| 亚洲一区二区视频在线观看| 日韩视频一区二区三区在线播放| 欧美日韩国产一区二区三区| 亚洲一区二区四区| 亚洲免费小视频| 国产亚洲精品资源在线26u| 久久久欧美精品| 久久久久久自在自线| 亚洲国产精品久久久久| 欧美激情一区二区三区全黄| 欧美乱大交xxxxx| 中文一区二区| 亚洲一区影院| 红桃视频国产精品| 亚洲第一福利社区| 欧美日韩在线高清| 久久精品国产清自在天天线| 久久久久久伊人| 99国产精品视频免费观看一公开| 一本色道久久综合亚洲精品不卡| 国产精品美女久久久久aⅴ国产馆| 午夜视频在线观看一区二区| 久久精品123| 亚洲狼人精品一区二区三区| 亚洲视频免费在线观看| 精品91免费| 亚洲人成人99网站| 国产日韩一区二区| 欧美成人综合在线| 国产精品剧情在线亚洲| 免费在线成人|