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

隨筆-341  評論-2670  文章-0  trackbacks-0
    今天為GacUI寫了一個新的Demo,展示了一些可以自動排版的按鈕。主要的設想就是在窗口上放一個表格,分成兩行兩列。上面的按鈕占滿一整行,下面兩個單元格放兩個按鈕。然后就可以設置每個行和列占整個表格的比例,在這個Demo里面都設置成50%。這樣每當窗口縮放的時候,按鈕的位置也會隨之重新排版。然后設置表格充滿整個窗口,這樣窗口的最小值就會被表格的內容所限定,這樣試圖把窗口縮小的時候,就會有一個最小的尺寸限制著,至始至終保證所有的東西都可以顯示出來,不會因為窗口太小而只顯示一半。按鈕也是同樣,可以設置它必須顯示所有的文字。所有的過程一旦配置好之后,計算尺寸的時候所有的操作都會自動做,程序員不需要為窗口的Resize事件寫任何代碼。

    下面先放圖。

    第一個圖是窗口剛剛打開的時候的樣子。因為Demo里面沒有設置窗口的尺寸,所以一上來就自動變成了最小的尺寸——并且剛好可以顯示所有的內容。



    第二個圖是窗口放大之后的樣子。Disable按鈕被按下了,所以上面的按鈕就變灰。



    這個Demo使用了Direct2D渲染器,所有的繪制過程都十分高速。而且表格的尺寸計算也是經過優化的,在拖放窗口的時候十分流暢。事實上按鈕的漸變啊、邊框啊、文字等等也是借助表格排版的。由于尺寸計算過于復雜,除了表格之外整個框架都不保存控件的尺寸,所有的東西都在需要的時候——譬如說渲染的時候,譬如說計算鼠標點中的位置——的那一刻才開始算。因此無論是鼠標滑過,或者是窗口拖放,都拼命地執行很多虛函數。可見C++的虛函數的性能之高,幾乎永遠都不會成為程序的瓶頸。下面來看代碼:

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

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

class EnableDisableWindow : public GuiWindow
{
private:
    GuiButton
*            buttonTarget;
    GuiButton
*            buttonEnable;
    GuiButton
*            buttonDisable;

    
void buttonEnable_OnClick(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        buttonTarget
->SetEnabled(true);
    }

    
void buttonDisable_OnClick(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
    {
        buttonTarget
->SetEnabled(false);
    }
public:
    EnableDisableWindow()
        :GuiWindow(GetCurrentTheme()
->CreateWindowStyle())
    {
        
this->SetText(L"Controls.Button.EnableDisable");
        
// limit the size that the window should always show the whole content without cliping it
        this->GetContainerComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);

        
// create a table to layout the 3 buttons
        GuiTableComposition* table=new GuiTableComposition;
        
// make the table to have 2 rows
        table->SetRowsAndColumns(22);
        table
->SetRowOption(0, GuiCellOption::PercentageOption(0.5));
        table
->SetRowOption(1, GuiCellOption::PercentageOption(0.5));
        table
->SetColumnOption(0, GuiCellOption::PercentageOption(0.5));
        table
->SetColumnOption(1, GuiCellOption::PercentageOption(0.5));
        
// dock the table to fill the window
        table->SetAlignmentToParent(Margin(10101010));
        
// add the table to the window;
        this->GetContainerComposition()->AddChild(table);

        
// add the target button
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            
// this cell is the top cell
            cell->SetSite(0012);

            buttonTarget
=g::NewButton();
            buttonTarget
->SetText(L"Enable or disable me using the buttons below!");
            
// ensure that the buttonTarget display the whole text
            buttonTarget->GetBoundsComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
            
// dock the button to fill the cell
            buttonTarget->GetBoundsComposition()->SetAlignmentToParent(Margin(0003));
            
// add the button to the cell
            cell->AddChild(buttonTarget->GetBoundsComposition());
        }

        
// add the enable button
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            
// this cell is the bottom left cell
            cell->SetSite(1011);

            buttonEnable
=g::NewButton();
            buttonEnable
->SetText(L"Enable");
            buttonEnable
->GetBoundsComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
            buttonEnable
->GetBoundsComposition()->SetAlignmentToParent(Margin(0330));
            buttonEnable
->Clicked.AttachMethod(this&EnableDisableWindow::buttonEnable_OnClick);
            cell
->AddChild(buttonEnable->GetBoundsComposition());
        }

        
// add the disable button
        {
            GuiCellComposition
* cell=new GuiCellComposition;
            table
->AddChild(cell);
            
// this cell is the bottom right cell
            cell->SetSite(1111);

            buttonDisable
=g::NewButton();
            buttonDisable
->SetText(L"Disable");
            buttonDisable
->GetBoundsComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
            buttonDisable
->GetBoundsComposition()->SetAlignmentToParent(Margin(3300));
            buttonDisable
->Clicked.AttachMethod(this&EnableDisableWindow::buttonDisable_OnClick);
            cell
->AddChild(buttonDisable->GetBoundsComposition());
        }

        
// change the button font
        {
            FontProperties font;

            font
=buttonTarget->GetFont();
            font.size
=20;
            buttonTarget
->SetFont(font);
            buttonEnable
->SetFont(font);
            buttonDisable
->SetFont(font);
        }

        
// 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()
        table->UpdateCellBounds();
        
// update the size
        this->SetBounds(Rect());
        
// move to the screen center
        this->MoveToScreenCenter();
    }

    
~EnableDisableWindow()
    {
    }
};

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

    代碼里面充滿了注釋,而且主要的內容也在上面介紹了,在這里我就不羅嗦了。所有的代碼都可以在http://gac.codeplex.com中,下載最新的代碼,然后在Libraries\GacUI\GacUIDemo\GacUIDemo.sln下面找到。
posted on 2012-04-25 02:46 陳梓瀚(vczh) 閱讀(2367) 評論(5)  編輯 收藏 引用 所屬分類: GacUI

評論:
# re: GacUI新Demo:按鈕和排版[未登錄] 2012-04-25 04:02 | me
superstar!  回復  更多評論
  
# re: GacUI新Demo:按鈕和排版[未登錄] 2012-04-25 18:20 | diryboy
好厲害!  回復  更多評論
  
# re: GacUI新Demo:按鈕和排版[未登錄] 2012-04-27 05:53 | koobin
是不是用Win7的API寫的?在XP下還運行不了?koobin@126.com  回復  更多評論
  
# re: GacUI新Demo:按鈕和排版 2012-04-27 06:09 | 陳梓瀚(vczh)
@koobin
應該只有剪貼板用到了win7的一個api,只要在xp的時候禁用即可。如果放在XP,最大的犧牲是沒有顯卡加速,要采用GDI來繪制,讓本來就慢的XP變得更慢了。  回復  更多評論
  
# re: GacUI新Demo:按鈕和排版 2013-05-15 23:28 | tb
厲害啊   回復  更多評論
  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美国产日本高清在线| 免费日韩av片| 欧美老女人xx| 国产精品爽爽ⅴa在线观看| 亚洲图片欧洲图片日韩av| 欧美国产日本韩| 久久久久久欧美| 国产精品一区免费视频| 午夜国产精品影院在线观看| 亚洲三级影院| 快she精品国产999| 樱桃国产成人精品视频| 亚洲大胆女人| 蜜桃久久精品乱码一区二区| 国产欧美91| 亚洲一区二区三区免费在线观看 | 亚洲黄色在线视频| 免费视频久久| 欧美亚洲免费电影| 亚洲一区二区高清| 亚洲淫片在线视频| 欧美日韩福利视频| 欧美日韩一区二区免费在线观看 | 国产精品拍天天在线| 欧美成人四级电影| 亚洲综合首页| 欧美女同视频| 国产亚洲人成a一在线v站 | 久久久久国产精品一区三寸| 中文久久乱码一区二区| 国产亚洲一区二区三区| 亚洲青色在线| 欧美在线短视频| 黄色成人在线网址| 久久精品欧洲| 一区二区三区四区五区在线| 久久先锋资源| 国产日韩在线一区| 亚洲二区在线视频| 激情欧美一区二区三区| 欧美在线黄色| 一区二区三区|亚洲午夜| 亚洲男女自偷自拍| 亚洲国产另类久久精品| 欧美国产综合视频| 久久久综合网站| 午夜精品久久久久久久99热浪潮| 欧美jizz19性欧美| 亚洲素人在线| 欧美午夜在线视频| 亚洲国产美女久久久久| 亚洲精品综合| 亚洲大胆女人| 久久精品国产免费观看| 国产最新精品精品你懂的| 欧美精品97| 韩国三级电影久久久久久| 亚洲免费福利视频| 亚洲欧洲日韩综合二区| 国产一二精品视频| 亚洲欧美国产高清| 日韩一级精品视频在线观看| 欧美a级一区| 先锋影音久久| 亚洲午夜羞羞片| 国产精品久久久久久久久久直播 | 国产欧美精品一区二区三区介绍| 狠狠色综合色区| 日韩视频在线观看国产| 国产一区导航| 亚洲免费av片| 精品1区2区3区4区| 欧美国产乱视频| 欧美福利精品| 亚洲女人天堂av| 久久偷窥视频| 亚洲精品日本| 欧美一区成人| 欧美一区二区三区精品电影| 欧美一区二区私人影院日本 | 久久综合色婷婷| 今天的高清视频免费播放成人| 久热精品视频在线观看| 亚洲免费在线视频| 国产精品久久久久久久久免费樱桃 | 国产女主播在线一区二区| 亚洲毛片在线| 亚洲一区网站| 亚洲图片欧洲图片日韩av| 亚洲三级影院| 99www免费人成精品| 日韩五码在线| 亚洲欧美日韩成人| 亚洲一区二区在线| 久久精品中文字幕一区| 国产午夜亚洲精品不卡| 国产精品久久久久三级| 国产精品久久久久久久久搜平片| 久久这里只有| 国产情人节一区| 欧美黄色一区二区| 国产专区精品视频| 欧美精品一区二区三区很污很色的| 国产精品私拍pans大尺度在线| 黄色日韩网站视频| 亚洲欧美国产毛片在线| 男人的天堂成人在线| 91久久在线观看| 久久av最新网址| 亚洲美女电影在线| 亚洲九九精品| 国产亚洲精品自拍| 国产精品成人播放| 国产精品久久久久aaaa九色| 亚洲欧美日韩一区二区在线 | 久久激情综合| 久久gogo国模裸体人体| 新片速递亚洲合集欧美合集| 欧美性大战久久久久久久| 欧美日本韩国| 欧美性淫爽ww久久久久无| 欧美激情第4页| 欧美激情第六页| 国产精品天天看| 国产一二精品视频| 欧美黑人国产人伦爽爽爽| 亚洲自拍偷拍福利| 亚洲欧美日韩精品综合在线观看| 精品1区2区3区4区| 亚洲欧洲在线一区| 久久综合伊人77777尤物| 欧美一级理论片| 久久这里只有| 国产日韩欧美一二三区| 日韩视频免费在线| 一区二区毛片| 欧美在线二区| 老司机亚洲精品| 最新国产乱人伦偷精品免费网站 | 亚洲欧美日韩国产另类专区| 亚洲精品免费看| 欧美wwwwww| 久久精品成人一区二区三区蜜臀 | 亚洲免费影视| 欧美大片在线观看一区| 欧美成人免费播放| 91久久精品国产91久久| 欧美了一区在线观看| 欧美一二三区在线观看| 久久一区欧美| 午夜欧美不卡精品aaaaa| 国产欧美一区二区三区久久| 欧美精品久久一区| 亚洲欧美日韩国产成人| 亚洲乱码久久| 欧美激情一级片一区二区| 亚洲欧美精品伊人久久| 亚洲国产综合视频在线观看| 欧美裸体一区二区三区| 欧美福利一区二区| 午夜精品久久久久久久99黑人| 亚洲国产经典视频| 国产精品美女久久久| 久热精品视频在线观看| 亚洲视频免费观看| 欧美国产激情| 先锋影音一区二区三区| 亚洲欧洲日产国码二区| 国产又爽又黄的激情精品视频| 欧美bbbxxxxx| 久久精品国产成人| 夜色激情一区二区| 老司机午夜精品视频| 日韩一二三区视频| 国产视频自拍一区| 国产农村妇女毛片精品久久莱园子 | 亚洲与欧洲av电影| 日韩香蕉视频| 在线观看欧美一区| 伊人蜜桃色噜噜激情综合| 国产精品自拍视频| 欧美大片在线观看| 国产精品午夜视频| 亚洲欧美日韩综合aⅴ视频| 夜夜嗨av一区二区三区网页| 99re6这里只有精品视频在线观看| 国产精品久久久久久五月尺| 欧美日韩中文字幕在线| 麻豆成人在线| 蜜桃伊人久久| 久久久五月婷婷| 老司机午夜精品视频| 欧美一区三区二区在线观看| 亚洲国产日韩欧美综合久久| 亚洲欧洲av一区二区三区久久| 亚洲综合色婷婷| 国产亚洲精品福利| 国产美女精品| 国内精品伊人久久久久av一坑| 国产精品成人在线|