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

隨筆-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>
            亚洲女人天堂成人av在线| 亚洲成色精品| 亚洲乱亚洲高清| 欧美~级网站不卡| 99re6热只有精品免费观看| 久久综合国产精品| 红杏aⅴ成人免费视频| 久久久欧美精品| 欧美一级淫片aaaaaaa视频| 欧美精品一区在线发布| 日韩天堂在线视频| 久久久91精品国产一区二区三区 | 久久精品国产久精国产爱| 国产精品久久国产精品99gif| 99精品欧美一区| 亚洲肉体裸体xxxx137| 欧美大秀在线观看| 亚洲欧美国产日韩中文字幕| 午夜精品一区二区三区在线| 亚洲国产日韩欧美在线动漫| 日韩网站在线观看| 亚洲精品国产精品国产自| 欧美视频亚洲视频| 久久婷婷麻豆| 欧美午夜在线观看| 欧美fxxxxxx另类| 国产精品久久久久久久一区探花 | 激情成人中文字幕| 日韩亚洲国产欧美| 激情综合网址| 亚洲无限乱码一二三四麻| 1024亚洲| 亚洲曰本av电影| 亚洲日韩成人| 久久精品午夜| 欧美一级欧美一级在线播放| 欧美韩日视频| 美女视频一区免费观看| 欧美无乱码久久久免费午夜一区 | 在线 亚洲欧美在线综合一区| 日韩亚洲精品电影| 亚洲国产成人久久综合一区| 亚洲午夜在线视频| 一区二区国产精品| 久久久国产精品亚洲一区| 午夜精品一区二区三区四区| 欧美aa国产视频| 美女露胸一区二区三区| 国产精品欧美激情| 99国产精品视频免费观看| 亚洲国产精品精华液网站| 欧美一区观看| 欧美主播一区二区三区| 欧美日韩精品久久| 91久久精品www人人做人人爽| 激情欧美一区二区| 久久精品国产99精品国产亚洲性色| 亚洲欧美日韩精品久久| 欧美福利一区二区三区| 欧美成人免费视频| 亚洲第一精品影视| 久久久欧美精品sm网站| 久久久欧美精品| 国产自产在线视频一区| 小处雏高清一区二区三区 | 国产一区二区三区久久悠悠色av| 亚洲午夜精品一区二区三区他趣| 中文一区字幕| 国产精品免费在线| 亚洲一区二区3| 欧美在线视频不卡| 国产一区二区三区久久| 欧美亚洲专区| 久久在线免费| 亚洲国产成人不卡| 欧美激情视频在线播放| 99re66热这里只有精品4| 亚洲少妇一区| 国产精品亚洲激情| 久久www免费人成看片高清| 久久免费的精品国产v∧| 国外精品视频| 美女视频黄a大片欧美| 欧美激情一区二区三区在线视频 | 国产精品亚洲精品| 欧美一站二站| 亚洲缚视频在线观看| 夜夜嗨av一区二区三区免费区| 欧美日韩国产精品一区| 午夜在线观看免费一区| 欧美成人免费在线| 一区二区三区精密机械公司 | 国产精品综合视频| 久久精品国产96久久久香蕉| 欧美激情精品久久久| 亚洲一区二区成人在线观看| 国产毛片久久| 猫咪成人在线观看| 亚洲一区二区三区高清| 免费一区二区三区| 亚洲影院高清在线| 亚洲第一区中文99精品| 国产精品国产三级国产普通话蜜臀| 欧美一级在线视频| 日韩图片一区| 免费欧美高清视频| 亚洲欧美日韩国产中文在线| 亚洲第一在线综合在线| 欧美午夜精品伦理| 两个人的视频www国产精品| 亚洲午夜久久久久久尤物| 免费视频一区| 欧美制服第一页| 一本色道久久综合亚洲91| 国内久久婷婷综合| 国产精品久久国产精麻豆99网站| 另类亚洲自拍| 欧美在线播放高清精品| 一区二区三区欧美成人| 亚洲电影av在线| 久久蜜臀精品av| 先锋影音国产精品| 一区二区三区**美女毛片| 在线观看欧美日本| 国产一区二区三区久久| 国产精品久久福利| 欧美日韩亚洲一区二区三区四区| 久久婷婷综合激情| 欧美在线播放一区| 亚洲在线观看免费视频| 亚洲美洲欧洲综合国产一区| 亚洲大片在线| 欧美激情一区二区三区高清视频| 久久免费偷拍视频| 久久精品一本久久99精品| 午夜日韩福利| 亚洲欧美综合国产精品一区| 国产精品99久久久久久有的能看| 亚洲激情视频在线播放| 亚洲国产精品福利| 亚洲国产你懂的| 一区精品在线| 在线国产欧美| 亚洲国产色一区| 91久久综合亚洲鲁鲁五月天| 亚洲国产精品久久久久| 亚洲国产三级| 一区二区日韩精品| 亚洲免费网站| 欧美一区二区三区的| 久久99伊人| 久久久夜精品| 亚洲二区免费| 99国产精品久久久久老师| 一本久道久久综合狠狠爱| 一区二区免费在线观看| 亚洲视频一区| 欧美在线视频播放| 另类酷文…触手系列精品集v1小说| 免费不卡在线观看| 欧美全黄视频| 国产麻豆91精品| 一区二区视频欧美| 一本久久a久久免费精品不卡| 亚洲午夜在线观看| 久久精品国产亚洲一区二区三区| 鲁大师影院一区二区三区| 亚洲电影av| 亚洲一区二区三区乱码aⅴ| 欧美在线视频一区| 美日韩精品免费观看视频| 欧美区二区三区| 国产精品一二三| 亚洲激情亚洲| 欧美一区二区高清在线观看| 欧美sm视频| 亚洲特级毛片| 久久午夜精品一区二区| 欧美视频国产精品| 在线成人www免费观看视频| 99re66热这里只有精品4| 久久电影一区| 亚洲国产mv| 欧美一区亚洲二区| 欧美美女bbbb| 在线欧美不卡| 性久久久久久久久| 欧美激情一区在线| 午夜精品视频在线观看| 欧美高清视频一区二区| 国产一二精品视频| 亚洲社区在线观看| 欧美成人精品一区二区| 亚洲在线成人精品| 欧美日韩国产页| 亚洲日本va午夜在线影院| 欧美在线观看视频| 99国产精品99久久久久久粉嫩| 久久女同互慰一区二区三区| 国产精品人人做人人爽人人添|