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

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

    下面先放圖。

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



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



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

#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;
}

    代碼里面充滿了注釋,而且主要的內(nèi)容也在上面介紹了,在這里我就不羅嗦了。所有的代碼都可以在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!  回復(fù)  更多評論
  
# re: GacUI新Demo:按鈕和排版[未登錄] 2012-04-25 18:20 | diryboy
好厲害!  回復(fù)  更多評論
  
# re: GacUI新Demo:按鈕和排版[未登錄] 2012-04-27 05:53 | koobin
是不是用Win7的API寫的?在XP下還運(yùn)行不了?koobin@126.com  回復(fù)  更多評論
  
# re: GacUI新Demo:按鈕和排版 2012-04-27 06:09 | 陳梓瀚(vczh)
@koobin
應(yīng)該只有剪貼板用到了win7的一個api,只要在xp的時候禁用即可。如果放在XP,最大的犧牲是沒有顯卡加速,要采用GDI來繪制,讓本來就慢的XP變得更慢了。  回復(fù)  更多評論
  
# re: GacUI新Demo:按鈕和排版 2013-05-15 23:28 | tb
厲害啊   回復(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>
            欧美午夜一区二区| 久久综合福利| 亚洲国产精品尤物yw在线观看| 国产精品扒开腿做爽爽爽软件 | 亚洲欧美日韩精品久久久| 亚洲视频在线观看视频| 亚洲欧美清纯在线制服| 久久精品91| 亚洲国产精品久久久久| 亚洲国产精品美女| 亚洲欧美成人一区二区在线电影| 欧美亚洲一区二区在线| 另类尿喷潮videofree| 欧美日韩一区二区三区在线视频| 国产美女精品视频| 亚洲精品一区二区三区福利| 午夜精品久久久久久久久久久久久| 久久久久久亚洲精品中文字幕 | 久久久www| 欧美日韩一区二区在线观看| 国产亚洲一区二区三区| 日韩一级裸体免费视频| 久久国产精品免费一区| 99国产精品99久久久久久| 久久精品伊人| 国产精品家教| 夜夜爽av福利精品导航| 蜜乳av另类精品一区二区| 日韩图片一区| 久久久久国产精品麻豆ai换脸| 欧美激情五月| 在线免费高清一区二区三区| 午夜精品剧场| 亚洲精品乱码久久久久久| 久久久久久一区二区| 国产精品九九久久久久久久| 亚洲乱码国产乱码精品精天堂| 久久精品国产久精国产爱| 日韩午夜激情电影| 免费亚洲一区二区| 国内精品久久久| 亚洲摸下面视频| 亚洲日韩欧美视频| 欧美v日韩v国产v| 国内自拍视频一区二区三区| 亚洲综合三区| 亚洲精品永久免费| 欧美高清视频一区二区三区在线观看| 国产日韩欧美综合| 欧美一区二区黄| 亚洲综合三区| 国产精品一页| 欧美诱惑福利视频| 欧美亚洲免费高清在线观看| 国产精品日本欧美一区二区三区| 中文高清一区| 久久精品久久99精品久久| 亚洲视频一区二区| 欧美日本亚洲韩国国产| 亚洲第一毛片| 欧美电影电视剧在线观看| 久久国产福利| 一区二区在线视频| 美女爽到呻吟久久久久| 久久久91精品国产| 影院欧美亚洲| 亚洲丰满在线| 欧美国产日韩a欧美在线观看| 亚洲人体大胆视频| 亚洲肉体裸体xxxx137| 欧美日韩视频免费播放| 亚洲欧美色一区| 亚洲综合电影| 海角社区69精品视频| 久久综合伊人77777尤物| 久久香蕉国产线看观看网| 亚洲福利av| 亚洲精品国产精品国自产观看浪潮| 欧美劲爆第一页| 亚洲伊人伊色伊影伊综合网 | 亚洲精品美女久久7777777| 欧美日本一区二区三区| 香蕉久久夜色| 久久亚洲二区| 亚洲午夜视频在线| 欧美专区一区二区三区| 亚洲日本免费| 亚洲女人天堂成人av在线| 在线精品亚洲一区二区| 一区二区毛片| 黄网站免费久久| 日韩视频免费观看| 国内成人精品2018免费看| 亚洲黄页一区| 国产一本一道久久香蕉| 91久久精品国产91久久| 国产精品视频精品| 亚洲第一精品夜夜躁人人爽 | 日韩视频在线播放| 亚洲欧美日韩精品久久久| 亚洲激情另类| 西西裸体人体做爰大胆久久久| 亚洲国产精品va在线观看黑人| 中文亚洲免费| 日韩午夜激情电影| 久久久综合网站| 亚洲欧美日韩精品久久亚洲区| 美女视频黄 久久| 久久裸体艺术| 国产日韩久久| 亚洲一区二区在线看| 99在线精品免费视频九九视| 久久人91精品久久久久久不卡| 午夜久久久久| 国产精品久久久久9999吃药| 亚洲人屁股眼子交8| 亚洲二区三区四区| 国产日韩av一区二区| 9l国产精品久久久久麻豆| 久久国产精品久久国产精品| 99在线观看免费视频精品观看| 久久久久久有精品国产| 久久成人羞羞网站| 欧美性jizz18性欧美| 91久久久亚洲精品| 亚洲国产导航| 久久亚洲国产精品日日av夜夜| 亚洲欧美中文另类| 欧美视频中文在线看| 亚洲精品婷婷| 一区二区三区视频观看| 欧美好骚综合网| 亚洲国产天堂网精品网站| 亚洲激情专区| 欧美91精品| 亚洲电影免费观看高清完整版| 在线精品视频一区二区| 久久免费高清| 欧美国产一区二区在线观看| 亚洲国产精品国自产拍av秋霞| 久久免费黄色| 欧美高清视频一区二区三区在线观看 | 久久综合久色欧美综合狠狠| 国产欧美日韩综合一区在线观看 | 欧美jjzz| 亚洲精品自在在线观看| 欧美日本高清视频| 一本色道久久综合精品竹菊| 亚洲欧美久久| 国一区二区在线观看| 蜜臀av一级做a爰片久久| 91久久精品国产| 亚洲欧美国产77777| 国产视频观看一区| 久色婷婷小香蕉久久| 亚洲欧洲综合| 欧美在线观看日本一区| 激情小说亚洲一区| 欧美激情国产日韩精品一区18| aa亚洲婷婷| 久久久精品国产免大香伊| 亚洲国产天堂网精品网站| 欧美图区在线视频| 欧美综合二区| 日韩午夜电影在线观看| 久久激情视频免费观看| 亚洲欧洲久久| 国产日韩精品在线播放| 欧美国产日韩精品| 亚洲欧美在线高清| 亚洲激情六月丁香| 久久精品国产成人| 一区二区三区视频在线| 精品动漫3d一区二区三区| 欧美日韩国产a| 久久久亚洲精品一区二区三区| 99精品国产高清一区二区| 国产精品国产精品| 欧美大尺度在线观看| 99re66热这里只有精品4| 国产精品久久久久9999| 美女任你摸久久| 午夜精品免费在线| 亚洲精品一区在线| 欧美成人免费一级人片100| 欧美一区二区三区视频免费| 亚洲精品1234| 国产丝袜一区二区| 国产精品二区二区三区| 欧美成人精品激情在线观看| 欧美一区高清| 亚洲免费一级电影| 亚洲精品在线三区| 欧美高清不卡| 另类欧美日韩国产在线| 久久精品在线免费观看| 亚洲综合日韩中文字幕v在线| 91久久精品一区二区别| 在线观看国产日韩| 国内外成人免费激情在线视频 |