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

隨筆-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) 閱讀(2363) 評論(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>
            99精品免费| 在线播放视频一区| 一区二区三区精品视频在线观看| 欧美激情国产日韩精品一区18| 久久久国产精品亚洲一区| 国自产拍偷拍福利精品免费一| 久久午夜激情| 欧美成人黑人xx视频免费观看| 日韩视频一区二区| 一区二区不卡在线视频 午夜欧美不卡'| 欧美日韩精品免费观看| 欧美一区二区三区四区高清| 久久久国产一区二区| 亚洲日本欧美| 亚洲网站在线播放| 精品福利电影| 日韩香蕉视频| 国内精品久久久久影院优 | 国产精品s色| 欧美在线视频观看免费网站| 久久久久久综合网天天| 亚洲精品一二三| 亚洲伊人第一页| 亚洲国产成人av在线| 一本色道久久88综合亚洲精品ⅰ | 亚洲国产毛片完整版 | 欧美高清视频一二三区| 欧美日韩一区在线| 蜜臀久久99精品久久久画质超高清| 欧美成人一区二区| 欧美一区二区三区视频在线| 欧美凹凸一区二区三区视频| 羞羞视频在线观看欧美| 欧美jjzz| 欧美1区2区| 国产网站欧美日韩免费精品在线观看| 欧美成人一区二区三区在线观看| 国产精品高潮在线| 亚洲国产精品激情在线观看| 国产欧美一区二区精品性| 亚洲欧洲一区二区三区在线观看| 国产亚洲成人一区| 中文在线资源观看网站视频免费不卡| 在线看视频不卡| 亚洲欧美日韩精品久久久| 日韩视频一区二区三区在线播放免费观看 | 香蕉成人久久| 亚洲影院免费| 欧美日本一道本在线视频| 久久亚洲一区二区三区四区| 国产精品国内视频| 亚洲精品国产精品国自产观看| 国产主播一区| 篠田优中文在线播放第一区| 亚洲欧美日韩久久精品 | 亚洲欧美国产精品桃花| 一区二区三区黄色| 欧美日本韩国| 亚洲精品免费在线播放| 亚洲国产高清一区| 另类国产ts人妖高潮视频| 久久综合国产精品| 国产主播一区二区| 欧美在线视频观看免费网站| 欧美影院成年免费版| 国产精品亚洲综合天堂夜夜| 亚洲天堂av在线免费观看| 亚洲午夜成aⅴ人片| 欧美三级韩国三级日本三斤| av不卡在线观看| 亚洲在线观看视频网站| 欧美视频一区二区| 亚洲深爱激情| 久久er精品视频| 韩国v欧美v日本v亚洲v| 久久久久五月天| 欧美国产大片| 中文欧美日韩| 国产日韩欧美自拍| 久久欧美肥婆一二区| 欧美激情一区二区久久久| 亚洲久久一区二区| 欧美日韩国产色综合一二三四| 亚洲精品欧美专区| 亚洲免费在线电影| 国产一区二区视频在线观看| 久久婷婷一区| 日韩亚洲欧美一区| 久久国产精彩视频| 亚洲高清在线播放| 欧美日韩成人在线| 午夜精品短视频| 欧美激情综合| 午夜视黄欧洲亚洲| 在线观看一区视频| 欧美午夜电影完整版| 欧美在线播放| 亚洲精品视频在线| 久久久久99| 一区二区三区不卡视频在线观看| 国产欧美日韩视频一区二区三区| 久久天天综合| 亚洲午夜在线| 亚洲激情视频在线| 欧美在线欧美在线| a91a精品视频在线观看| 国产日韩专区| 欧美日韩在线免费视频| 久久精品一级爱片| 亚洲天堂免费观看| 亚洲国产第一页| 久久精品视频在线看| 一区二区三区精品在线| 亚洲第一偷拍| 国产视频在线观看一区二区三区| 欧美国产一区二区| 久久精品一区二区三区中文字幕 | 羞羞答答国产精品www一本| 亚洲国产精品va在线看黑人动漫| 香蕉视频成人在线观看| 亚洲毛片av| 亚洲国产精品99久久久久久久久| 国产精品综合色区在线观看| 欧美高清免费| 久久夜色精品亚洲噜噜国产mv| 亚洲欧美国产精品专区久久| 亚洲精品欧美激情| 亚洲高清自拍| 老司机久久99久久精品播放免费| 午夜欧美视频| 午夜亚洲福利| 亚洲欧美一区二区三区极速播放| 日韩一级二级三级| 亚洲国产第一| 亚洲黄色成人久久久| 影视先锋久久| 在线观看欧美日韩国产| 在线成人激情| 亚洲国产精品精华液网站| 国产亚洲欧美另类中文| 国产精品一区免费在线观看| 国产精品久久久久久超碰| 欧美日韩一区二区三区在线观看免| 欧美高清不卡在线| 欧美电影免费观看高清| 免费日韩av| 欧美国产日韩一区二区在线观看| 免费欧美日韩| 欧美日本韩国一区二区三区| 欧美黄污视频| 国产精品99免费看 | 一区二区久久| 亚洲午夜电影在线观看| 亚洲欧美另类中文字幕| 午夜精品久久久久久99热| 亚洲欧美久久久| 久久国产精品免费一区| 久久亚洲春色中文字幕| 美女精品国产| 亚洲欧洲综合| 一区二区欧美亚洲| 亚洲欧美日韩精品综合在线观看| 午夜日韩电影| 久久综合伊人| 欧美日韩在线播放三区四区| 国产欧美 在线欧美| 黄色成人免费观看| 亚洲精品综合精品自拍| 中文日韩欧美| 久久亚洲精品一区| 亚洲国产精品成人精品| 99re国产精品| 亚洲欧美在线播放| 免费短视频成人日韩| 欧美日韩一区二区三区高清| 国产婷婷色一区二区三区四区| 亚洲国产精品女人久久久| 亚洲视频中文| 欧美a级大片| 这里只有精品视频在线| 久久精品一区| 欧美三级午夜理伦三级中视频| 国产亚洲欧美在线| 夜夜嗨av一区二区三区网页| 久久久久国产一区二区三区四区| 亚洲第一精品福利| 亚洲欧美电影院| 欧美激情在线有限公司| 国产美女一区二区| 99在线|亚洲一区二区| 久久嫩草精品久久久精品| 亚洲美女av黄| 免费在线成人| 国产综合视频| 一区二区三区精品视频| 蜜臀av国产精品久久久久| 在线视频日韩精品| 欧美激情精品久久久久久变态 | 蜜臀av一级做a爰片久久| 国产啪精品视频|