Chapter 2- GUI API.ppt
《Chapter 2- GUI API.ppt》由会员分享,可在线阅读,更多相关《Chapter 2- GUI API.ppt(45页珍藏版)》请在麦多课文档分享上搜索。
1、Chapter 2,Chapter 2: GUI API,Chapter 2,GUI API,Software Library Support Event Driven Programming Front end for users and Back end for us programmers Via GUI Elements,Chapter 2,GUI Application Front end,Building the front end: GUI Element Layout,Chapter 2,GUI Element,Elements for interacting with use
2、rs E.g., A Window: for containing buttons and mouse E.g., Buttons for user to click-on,Chapter 2,GUI Elements: User Perspective,Virtual IO devices For users to express their wishes (to our applications) Relate to past experiences Visually pleasing: icons that looks like a real button 3D looking, sho
3、ws depressed (or change color) Semantically meaningful: A button that behaves like a real button: clicked and something will happen,Chapter 2,GUI Application Back end,“responding” to the front-end GUI Elements,Chapter 2,GUI Elements: Programmer perspective,Unique ID: To identify the element (in prog
4、ramming code) Behavior: Default: e.g., check-box shows a check-mark Customizable: e.g., check-box disappears after checked Semantic State Information: E.g., check box: checked (true) or not checked (false) E.g., slider bar: has a current value We must worry about how to access this information,Chapt
5、er 2,GUI Elements: Programmer perspective continue,Abstraction representation: our program interacts with data type E.g., CButton, CSliderBar Event Service Registration How to register for events and services E.g., when clicked on checked box, call this function Control Variables: Variables in our p
6、rogram representing the front-end GUI elements,Chapter 2,Relation to previous lecture:,Previously: Event driven programming Application State (persistent variables) Design Workflow (events) User intuitive actions to change the application state With Workflows Design event service routines (to update
7、 the application state) Register event services Complete solution! But how to implement this solution? GUI API!,Chapter 2,GUI API: must support ,Front end design: GUI builder Backend: Control variables Mechanism for linking GUI element to control variables Event Service Registrations Call back funct
8、ions Inheritance override,Chapter 2,GUI API Example: MFC,Front end: Resource Editor Integrated in Visual Studio IDE,Chapter 2,MFC: Back end GUI Elements,Chapter 2,MFC/VS: Implementation Files,Chapter 2,MFC/VS: files,TutorialApp: This is the application TutorialDlg: The main dialog window This is a G
9、UI element! (One instance of this object defined in TutorialApp) .rc: For GUI Builder (Resource editor) Text file, can open with text editor .vcproj, .sln: VS IDE files .sui, .ncb: VS IDE scratch files .ico and rc2: icons for the app DEBUIG/Release: build results,Chapter 2,Tutorial 2.1:,CTutorialApp
10、: is the application dlg the application window A instance of CTutorialDlg defined in CTutorialApp:InitInstance() Is the control variable for our application window CTutorialDlg:OnInitDialog() SystemInitialization() for Creating application state Registration of event handlers CTutorialDlg:OnPaint()
11、 When redraw is necessary BEGIN_MESAGE_MAP For overriding event services,Chapter 2,Tutorial: 2.1 .rc file,Chapter 2,Tutorial 2.2:,Application State: An integer (count) Events: React to click on Add button React to click on Quit button,Chapter 2,Tutorial 2.2: Implementation,Chapter 2,Tutorial 2.2: ba
12、ckend,The CTutorialDlg class,Chapter 2,Tutorial 2.2: CTutorialDlg.cpp,System initializationControl Variable/GUI element assocationDDX_Text links GUI element (IDC_ECHO_AREA) control variable (m_EchoText)Button event registration:,Chapter 2,Tutorial 2.2: button event service,UpdateData() Ture: stream
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CHAPTER2GUIAPIPPT
