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

隨筆-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>
            欧美一区二区在线免费播放| 裸体一区二区三区| 亚洲直播在线一区| 欧美高清在线视频| 久久激情综合网| 国产日韩欧美a| 欧美一级日韩一级| 亚洲男女自偷自拍图片另类| 欧美日韩在线高清| 亚洲视频专区在线| 日韩视频中文| 欧美视频中文字幕| 亚洲一区二区动漫| 亚洲精品日韩精品| 欧美日韩亚洲系列| 亚洲一区日韩在线| 亚洲欧美在线免费| 国产亚洲成av人在线观看导航| 羞羞漫画18久久大片| 亚洲资源在线观看| 国产一区二区成人| 欧美18av| 欧美日韩国产在线| 午夜天堂精品久久久久| 欧美一区二区在线免费观看| 伊人男人综合视频网| 欧美激情在线免费观看| 欧美日韩亚洲不卡| 欧美在线一区二区三区| 久久久.com| 日韩亚洲精品在线| 亚洲网站在线| 亚洲第一二三四五区| 91久久久久久| 久久久www成人免费精品| 亚洲欧美美女| 在线观看精品一区| 亚洲国产视频一区| 国产精品免费电影| 免费黄网站欧美| 欧美在线视频免费播放| 午夜精品国产更新| 免费欧美日韩| 欧美成年人视频| 亚洲曰本av电影| 先锋影音网一区二区| 亚洲国产欧美日韩| 亚洲视频一区二区在线观看 | 妖精视频成人观看www| 在线亚洲免费| 国产视频亚洲精品| 欧美激情a∨在线视频播放| 欧美三级网址| 蜜桃av一区| 国产精品激情电影| 欧美成人日韩| 国产日韩欧美高清免费| 亚洲日本va午夜在线影院| 国产裸体写真av一区二区| 亚洲国产小视频在线观看| 国产日本欧美在线观看| 亚洲欧洲精品一区二区三区波多野1战4| 国产精品免费网站| 亚洲国产另类 国产精品国产免费| 亚洲综合色激情五月| 亚洲精品欧美日韩| 久久久www成人免费无遮挡大片 | 在线亚洲欧美视频| 亚洲国产成人不卡| 午夜欧美电影在线观看| 亚洲图中文字幕| 免费影视亚洲| 老司机成人网| 亚洲成人影音| 亚洲精品中文字幕女同| 国产在线一区二区三区四区| 中文在线资源观看网站视频免费不卡| 亚洲大胆女人| 久久大逼视频| 亚洲综合国产激情另类一区| 免费看av成人| 女生裸体视频一区二区三区| 国产一区在线视频| 亚洲欧美国内爽妇网| 亚洲一区二区成人| 欧美日韩亚洲综合在线| 亚洲精品国产精品乱码不99| 亚洲日本无吗高清不卡| 欧美a级一区| 亚洲福利免费| 亚洲精品偷拍| 欧美精品久久久久a| 亚洲精品一区二区三区在线观看| 亚洲美女诱惑| 欧美日韩一区二区三区在线观看免| 亚洲欧洲日产国码二区| 99国产精品久久久久老师| 欧美乱大交xxxxx| 亚洲精品乱码视频| 中文一区二区| 国产精品毛片大码女人| 国产精品电影在线观看| 女同性一区二区三区人了人一| 黑人巨大精品欧美一区二区小视频 | 美女成人午夜| 亚洲国产精品va在线观看黑人| 亚洲精品国精品久久99热一| 欧美精品一区二区三区蜜桃 | 麻豆精品传媒视频| 欧美激情精品| 夜夜爽99久久国产综合精品女不卡| 欧美精品亚洲精品| 亚洲午夜一级| 久久久久久伊人| 亚洲国产日韩欧美综合久久| 欧美精品在线免费播放| 亚洲午夜高清视频| 久久综合久久综合这里只有精品 | 久久精品1区| 伊人久久av导航| 欧美经典一区二区三区| 99成人在线| 久久久亚洲高清| 99re国产精品| 国产精品视频免费观看www| 久久久7777| 日韩亚洲欧美在线观看| 久久久精品久久久久| 亚洲另类自拍| 国产香蕉97碰碰久久人人| 欧美1级日本1级| 亚洲欧美日韩国产成人精品影院| 欧美电影资源| 欧美影院午夜播放| 日韩一区二区精品葵司在线| 国产一区二区看久久| 欧美日韩色综合| 久久亚洲私人国产精品va媚药 | 欧美激情一区二区三级高清视频| 亚洲一区二区三区欧美| 欧美激情一区在线观看| 久久国产精品72免费观看| 亚洲精品久久7777| 国际精品欧美精品| 欧美视频日韩| 欧美成人精品在线| 欧美一区二区三区在线观看| 亚洲精品乱码久久久久久蜜桃麻豆 | 香蕉av福利精品导航| 在线观看日韩欧美| 国产精品对白刺激久久久| 久久影院亚洲| 午夜视频在线观看一区| 日韩视频一区二区在线观看| 美日韩精品视频免费看| 欧美一区二区三区喷汁尤物| 一本色道久久综合狠狠躁篇怎么玩| 亚洲淫性视频| 亚洲欧洲一区二区在线观看| 国产一区二区日韩| 国产精品国产三级国产普通话蜜臀| 欧美成人综合网站| 久久亚洲综合网| 久久精品国产99国产精品| 亚洲主播在线观看| 一本色道久久综合狠狠躁篇的优点| 欧美激情精品久久久久久大尺度 | 亚洲第一伊人| 亚洲欧美乱综合| 亚洲国产日韩一区| 久久久久久久国产| 午夜精品久久久久久久久久久| 99国产精品| 一本久道综合久久精品| 91久久精品日日躁夜夜躁国产| 樱花yy私人影院亚洲| 极品少妇一区二区三区精品视频| 亚洲视屏一区| 日韩一级不卡| 日韩一级黄色大片| 日韩一区二区福利| 一区二区三区视频在线| 一区二区三区你懂的| 一本久久a久久免费精品不卡| 日韩一级大片| 亚洲欧美日韩系列| 香蕉成人伊视频在线观看| 午夜免费日韩视频| 小黄鸭精品密入口导航| 久久精品一区二区国产| 久久久久五月天| 欧美不卡一卡二卡免费版| 欧美韩国日本综合| 欧美涩涩网站| 国产亚洲女人久久久久毛片| 1024精品一区二区三区| 99国内精品久久| 性欧美1819性猛交| 猛男gaygay欧美视频| 亚洲国产一区二区三区高清|