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

隨筆-341  評論-2670  文章-0  trackbacks-0
    GacUI添加了一個新的Demo。這個Demo用了幾個按鈕(之所以不用菜單是因為不想讓Demo一下子包含太多新東西)來實現剪貼板操作、只讀控制和行跳轉等功能。在剪貼板里面的內容是文字的時候,Paste按鈕會被Enable。這個過程是自動的,也就是說,你在畫圖里面復制了一個圖片,這個按鈕也會變灰。Cut和Copy按鈕僅在文本框有文字被選中的時候可用,因此相應了文本框的SelectionChanged來處理這件事情。如果文本框的內容太多的話,{VS, Explorer} X {Debug, Release}這四種運行方法里面,只有在Debug模式下掛了VS這種情況會感覺有點卡,其他的打開方法都是很流暢的。先來看圖:



    代碼還是比較簡單的。先用一個Table分成三行,前兩行讓行高縮短到最短,最后一行則利用了剩余空間的100%撐開。前兩行里面的按鈕用Stack來對它們進行排版。單行文本框沒有最小高度,所以依靠Stack和Table,它的高度會保持跟按鈕一致。代碼如下:

  1 #include "..\..\Public\Source\GacUIIncludes.h"
  2 #include <Windows.h>
  3 
  4 int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int CmdShow)
  5 {
  6     return SetupWindowsDirect2DRenderer();
  7 }
  8 
  9 class TextBoxEditorWindow : public GuiWindow
 10 {
 11 private:
 12     GuiButton*                        buttonCut;
 13     GuiButton*                        buttonCopy;
 14     GuiButton*                        buttonPaste;
 15     GuiButton*                        buttonSelectAll;
 16     GuiSelectableButton*            checkReadonly;
 17     GuiSinglelineTextBox*            textGoto;
 18     GuiButton*                        buttonGoto;
 19     GuiMultilineTextBox*            textDocument;
 20 
 21     void UpdateEditButtonState()
 22     {
 23         buttonCut->SetEnabled(textDocument->CanCut());
 24         buttonCopy->SetEnabled(textDocument->CanCopy());
 25         buttonPaste->SetEnabled(textDocument->CanPaste());
 26     }
 27 
 28     // ensure that the buttonGoto is enabled only when textGoto's content is a positive number
 29     void UpdateGotoButtonState()
 30     {
 31         buttonGoto->SetEnabled(utow(wtou(textGoto->GetText()))==textGoto->GetText() && wtou(textGoto->GetText())!=0);
 32     }
 33 
 34     // cut text box selection
 35     void buttonCut_OnClicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 36     {
 37         textDocument->Cut();
 38         textDocument->SetFocus();
 39     }
 40 
 41     // copy text box selection
 42     void buttonCopy_OnClicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 43     {
 44         textDocument->Copy();
 45         textDocument->SetFocus();
 46     }
 47 
 48     // paste text from clipboard
 49     void buttonPaste_OnClicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 50     {
 51         textDocument->Paste();
 52         textDocument->SetFocus();
 53     }
 54 
 55     // select all text
 56     void buttonSelectAll_OnClicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 57     {
 58         textDocument->SelectAll();
 59         textDocument->SetFocus();
 60     }
 61 
 62     // go to the specified line
 63     void buttonGoto_OnClicked(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 64     {
 65         int line=wtoi(textGoto->GetText())-1;
 66         textDocument->Select(TextPos(line, 0), TextPos(line, 0));
 67         textDocument->SetFocus();
 68     }
 69 
 70     // make the textbox readonly or not readonly
 71     void checkReadonly_OnSelectedChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 72     {
 73         textDocument->SetReadonly(checkReadonly->GetSelected());
 74         UpdateEditButtonState();
 75     }
 76 
 77     // when textGoto changed, disable buttonGoto if the text in the textGoto is failed to pass the validation
 78     void textGoto_TextChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 79     {
 80         UpdateGotoButtonState();
 81     }
 82 
 83     // update the edit buttons when selection changed
 84     void textDocument_SelectionChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 85     {
 86         UpdateEditButtonState();
 87     }
 88     
 89     // update the edit buttons when clipboard changed changed
 90     void window_OnClipboardUpdated(GuiGraphicsComposition* sender, GuiEventArgs& arguments)
 91     {
 92         UpdateEditButtonState();
 93     }
 94 public:
 95     TextBoxEditorWindow()
 96         :GuiWindow(GetCurrentTheme()->CreateWindowStyle())
 97     {
 98         this->SetText(L"Controls.TextBox.Editor");
 99         this->GetContainerComposition()->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
100         this->ClipboardUpdated.AttachMethod(this&TextBoxEditorWindow::window_OnClipboardUpdated);
101 
102         GuiTableComposition* table=new GuiTableComposition;
103         table->SetAlignmentToParent(Margin(0000));
104         table->SetCellPadding(2);
105         table->SetRowsAndColumns(31);
106         table->SetRowOption(0, GuiCellOption::MinSizeOption());
107         table->SetRowOption(1, GuiCellOption::MinSizeOption());
108         table->SetRowOption(2, GuiCellOption::PercentageOption(1.0));
109         table->SetColumnOption(0, GuiCellOption::PercentageOption(1.0));
110         this->GetContainerComposition()->AddChild(table);
111         
112         {
113             GuiCellComposition* cell=new GuiCellComposition;
114             table->AddChild(cell);
115             cell->SetSite(0011);
116 
117             GuiStackComposition* stack=new GuiStackComposition;
118             stack->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
119             stack->SetPadding(2);
120             stack->SetAlignmentToParent(Margin(0000));
121             cell->AddChild(stack);
122 
123             {
124                 GuiStackItemComposition* item=new GuiStackItemComposition;
125                 stack->AddChild(item);
126 
127                 buttonCut=g::NewButton();
128                 buttonCut->SetText(L"Cut");
129                 buttonCut->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
130                 buttonCut->Clicked.AttachMethod(this&TextBoxEditorWindow::buttonCut_OnClicked);
131                 item->AddChild(buttonCut->GetBoundsComposition());
132             }
133             {
134                 GuiStackItemComposition* item=new GuiStackItemComposition;
135                 stack->AddChild(item);
136 
137                 buttonCopy=g::NewButton();
138                 buttonCopy->SetText(L"Copy");
139                 buttonCopy->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
140                 buttonCopy->Clicked.AttachMethod(this&TextBoxEditorWindow::buttonCopy_OnClicked);
141                 item->AddChild(buttonCopy->GetBoundsComposition());
142             }
143             {
144                 GuiStackItemComposition* item=new GuiStackItemComposition;
145                 stack->AddChild(item);
146 
147                 buttonPaste=g::NewButton();
148                 buttonPaste->SetText(L"Paste");
149                 buttonPaste->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
150                 buttonPaste->Clicked.AttachMethod(this&TextBoxEditorWindow::buttonPaste_OnClicked);
151                 item->AddChild(buttonPaste->GetBoundsComposition());
152             }
153             {
154                 GuiStackItemComposition* item=new GuiStackItemComposition;
155                 stack->AddChild(item);
156 
157                 buttonSelectAll=g::NewButton();
158                 buttonSelectAll->SetText(L"Select All");
159                 buttonSelectAll->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
160                 buttonSelectAll->Clicked.AttachMethod(this&TextBoxEditorWindow::buttonSelectAll_OnClicked);
161                 item->AddChild(buttonSelectAll->GetBoundsComposition());
162             }
163             {
164                 GuiStackItemComposition* item=new GuiStackItemComposition;
165                 stack->AddChild(item);
166 
167                 checkReadonly=g::NewCheckBox();
168                 checkReadonly->SetText(L"Readonly");
169                 checkReadonly->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
170                 checkReadonly->SelectedChanged.AttachMethod(this&TextBoxEditorWindow::checkReadonly_OnSelectedChanged);
171                 item->AddChild(checkReadonly->GetBoundsComposition());
172             }
173         }
174         {
175             GuiCellComposition* cell=new GuiCellComposition;
176             table->AddChild(cell);
177             cell->SetSite(1011);
178 
179             GuiStackComposition* stack=new GuiStackComposition;
180             stack->SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren);
181             stack->SetPadding(2);
182             stack->SetAlignmentToParent(Margin(0000));
183             cell->AddChild(stack);
184 
185             {
186                 GuiStackItemComposition* item=new GuiStackItemComposition;
187                 stack->AddChild(item);
188 
189                 textGoto=g::NewTextBox();
190                 textGoto->GetBoundsComposition()->SetBounds(Rect(Point(00), Size(1800)));
191                 textGoto->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
192                 textGoto->TextChanged.AttachMethod(this&TextBoxEditorWindow::textGoto_TextChanged);
193                 item->AddChild(textGoto->GetBoundsComposition());
194             }
195             {
196                 GuiStackItemComposition* item=new GuiStackItemComposition;
197                 stack->AddChild(item);
198 
199                 buttonGoto=g::NewButton();
200                 buttonGoto->SetText(L"Go to this line");
201                 buttonGoto->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
202                 buttonGoto->Clicked.AttachMethod(this&TextBoxEditorWindow::buttonGoto_OnClicked);
203                 item->AddChild(buttonGoto->GetBoundsComposition());
204             }
205         }
206         {
207             GuiCellComposition* cell=new GuiCellComposition;
208             table->AddChild(cell);
209             cell->SetSite(2011);
210 
211             textDocument=g::NewMultilineTextBox();
212             textDocument->GetBoundsComposition()->SetAlignmentToParent(Margin(0000));
213             textDocument->SelectionChanged.AttachMethod(this&TextBoxEditorWindow::textDocument_SelectionChanged);
214             cell->AddChild(textDocument->GetBoundsComposition());
215         }
216 
217         // make some buttons enabled or disabled appropiately
218         UpdateEditButtonState();
219         UpdateGotoButtonState();
220         // set the preferred minimum client size
221         this->GetBoundsComposition()->SetPreferredMinSize(Size(640480));
222         // call this to calculate the size immediately if any indirect content in the table changes
223         // so that the window can calcaulte its correct size before calling the MoveToScreenCenter()
224         this->ForceCalculateSizeImmediately();
225         // move to the screen center
226         this->MoveToScreenCenter();
227     }
228 
229     ~TextBoxEditorWindow()
230     {
231     }
232 };
233 
234 void GuiMain()
235 {
236     GuiWindow* window=new TextBoxEditorWindow();
237     GetApplication()->Run(window);
238     delete window;
239 }

    GacUI將提供兩個文本框的Demo,這是第一個。GacUI的文本框從一開始就具備了讓每一個字符的顏色可以不同的功能,下一個Demo將展示如何利用使用正則表達式構建的詞法分析器(見這里這里),讓文本框在編輯的時候,跟所有的代碼編輯器一樣,可以根據情況把不同的字符串染成不同的顏色。
posted on 2012-05-05 02:37 陳梓瀚(vczh) 閱讀(5346) 評論(5)  編輯 收藏 引用 所屬分類: GacUI

評論:
# re: GacUI Demo:文本框基本應用 2012-05-05 08:24 | 空明流轉
基本成型了。。。  回復  更多評論
  
# re: GacUI Demo:文本框基本應用[未登錄] 2012-05-06 02:10 | me
你太厲害了!別太累哦!  回復  更多評論
  
# re: GacUI Demo:文本框基本應用 2012-05-06 05:28 | Zblc(邱震鈺)
不容易瓦  回復  更多評論
  
# re: GacUI Demo:文本框基本應用 2012-05-07 00:14 | vczh
公司發winphone7.5手機了滅哈哈。  回復  更多評論
  
# re: GacUI Demo:文本框基本應用[未登錄] 2012-05-07 16:37 | me
哇哇哇!!!  回復  更多評論
  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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久久香蕉国产| 蜜桃av综合| 欧美激情精品久久久久久免费印度| 亚洲黄色免费| 亚洲日韩视频| 国产精品高潮呻吟久久| 欧美一级片在线播放| 久久国产精品久久久久久| 在线观看精品一区| 亚洲激情网站免费观看| 欧美三级乱码| 久久米奇亚洲| 欧美激情精品久久久久久大尺度| 一区二区三区视频在线播放| 亚洲欧美日韩视频二区| 一区在线电影| 亚洲伦理自拍| 国产视频亚洲精品| 亚洲经典视频在线观看| 国产精品女主播一区二区三区| 久久久成人精品| 欧美精品色一区二区三区| 亚洲综合三区| 久久综合亚洲社区| 亚洲综合久久久久| 男人的天堂成人在线| 亚洲欧美日韩一区二区在线 | 久久精品欧美| 欧美大片在线观看一区| 久久riav二区三区| 欧美黄色片免费观看| 久久成人精品| 欧美色网在线| 欧美大片一区| 国产人久久人人人人爽| 亚洲精品社区| 亚洲电影有码| 午夜精品99久久免费| 一本在线高清不卡dvd| 久久久亚洲国产美女国产盗摄| 亚洲天堂男人| 欧美大尺度在线观看| 久久久久久久一区二区三区| 欧美日韩亚洲高清一区二区| 欧美成人亚洲成人| 国产日韩精品一区二区| 在线视频欧美精品| 99热免费精品在线观看| 美国十次成人| 免费欧美高清视频| 国产一区二区毛片| 亚洲一区制服诱惑| 亚洲一区二区三区乱码aⅴ蜜桃女| 久久综合色影院| 久久婷婷久久一区二区三区| 国产麻豆日韩| 亚洲综合丁香| 欧美在线www| 国产精品嫩草99av在线| 一区二区三区欧美在线| 亚洲一级黄色av| 欧美日韩精品免费在线观看视频| 亚洲第一在线综合网站| 伊人成综合网伊人222| 久久久久一区二区| 男人插女人欧美| 亚洲国产毛片完整版| 麻豆精品91| 亚洲国产日韩欧美在线动漫| 亚洲欧洲日产国产综合网| 欧美成人一区在线| 日韩视频一区二区三区在线播放免费观看| 最新亚洲激情| 国产精品99免视看9| 亚洲欧美日韩中文播放| 久久久久久亚洲精品杨幂换脸| 国产午夜精品视频| 另类春色校园亚洲| 亚洲电影在线播放| 亚洲精品在线观| 欧美日韩综合在线| 香蕉av777xxx色综合一区| 久久亚洲精品视频| 亚洲国产欧洲综合997久久| 欧美激情视频免费观看| 亚洲桃色在线一区| 久久午夜色播影院免费高清| 亚洲国产精品va在线看黑人| 欧美片网站免费| 亚洲一区视频在线观看视频| 久久人人超碰| 99re8这里有精品热视频免费| 国产精品vvv| 久久偷看各类wc女厕嘘嘘偷窃| 91久久在线视频| 欧美一区免费视频| 亚洲日本成人| 国产精品羞羞答答| 蜜臀a∨国产成人精品| 99精品福利视频| 免费一区二区三区| 亚洲一区二区三区中文字幕在线| 国产性做久久久久久| 欧美夫妇交换俱乐部在线观看| 亚洲综合日韩中文字幕v在线| 免费久久99精品国产自| 午夜精品福利在线观看| 亚洲国产日韩欧美在线图片| 国产精品欧美风情| 欧美激情国产日韩| 久久精品国产99国产精品| 日韩亚洲精品电影| 牛夜精品久久久久久久99黑人 | 国产精品视频yy9099| 久久在线视频| 亚洲欧美日本另类| 99精品欧美| 欧美激情a∨在线视频播放| 欧美一区二区三区成人| 亚洲青涩在线| 在线不卡欧美| 国产一区美女| 国产精品第一页第二页第三页| 欧美成在线观看| 久久中文字幕一区| 久久www成人_看片免费不卡| 一区二区福利| 一本大道久久a久久综合婷婷| 欧美激情精品久久久久久蜜臀| 久久激情综合网| 欧美一区二区三区四区在线观看| 亚洲三级免费观看| 136国产福利精品导航网址| 国产日本精品| 国产一级精品aaaaa看| 国产九九精品| 国产精品久久久久av免费| 欧美视频官网| 欧美色图天堂网| 欧美午夜电影在线观看| 国产精品高潮呻吟视频| 欧美午夜宅男影院| 国产精品第一区| 国产精品一区二区久久精品| 国产精品日韩一区二区三区| 欧美视频在线不卡| 国产精品v欧美精品v日韩精品| 欧美天天综合网| 欧美婷婷六月丁香综合色| 一片黄亚洲嫩模| 99视频在线观看一区三区| 日韩一区二区电影网| 一区二区三区www| 亚洲少妇最新在线视频| 午夜精品免费在线| 欧美一区二区三区成人| 久久久蜜臀国产一区二区| 久久在线免费| 欧美激情综合色综合啪啪 | 9l视频自拍蝌蚪9l视频成人| 亚洲免费观看高清完整版在线观看熊 | 在线观看欧美日韩国产| 亚洲国产精品va在线看黑人| 亚洲美女诱惑| 亚洲综合精品自拍| 久久精品免费看| 免费欧美在线视频| 亚洲精品在线视频| 亚洲午夜av电影| 久久久久国产精品www| 欧美精品一区三区| 国产精品专区h在线观看| 伊人久久大香线| 亚洲天堂男人| 美女尤物久久精品| 在线亚洲欧美| 久久久国产91| 欧美日韩亚洲综合| 国产一区二区三区黄视频| 亚洲伦伦在线| 久久精品免费播放| 91久久久久久国产精品| 亚洲午夜视频在线观看| 久久伊人免费视频| 国产精品美女久久久浪潮软件 | 欧美色精品天天在线观看视频| 国产精品亚洲综合天堂夜夜| 在线日韩中文| 欧美在线观看天堂一区二区三区 | 亚洲欧美日韩第一区| 久久久蜜桃一区二区人| av成人免费在线观看| 欧美jizz19hd性欧美| 国内精品亚洲| 欧美在线播放高清精品|