2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩26頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、<p>  題目名稱: wxWidgets Technology Introduction </p><p>  譯文題目: wxWidgets技術簡介 </p><p>  原文題目: wxWidgets Technology Introduction </

2、p><p>  原文出處: http://www.wxwidgets.org/ </p><p>  Programming with wxWidgets</p><p>  In this article, we answer a few basic questions about what

3、wxWidgets is and what sets it apart from other solutions. We outline the project’s history, how the wxWidgets community works, how wxWidgets is licensed, and an overview of the architecture and available parts.</p>

4、<p>  1.1 WHAT IS WXWIDGETS?</p><p>  wxWidgets is a programmer’s toolkit for writing desktop or mobile applications with graphical user interfaces (GUIs). It’s a framework, in the sense that it does

5、a lot of the housekeeping work and provides default application behavior. The wxWidgets library contains a large number of classes and methods for the programmer to use and customize. Applications typically show windows

6、containing standard controls, possibly drawing specialized images and graphics and responding to input from the mouse,</p><p>  While wxWidgets is often labeled a GUI development toolkit, it is in fact much

7、more than that and has features that are useful for many aspects of application development. This has to be the case because all of a wxWidgets application needs to be portable to different platforms, not just the GUI pa

8、rt. wxWidgets provides classes for files and streams, multiple threads, application settings, interprocess communication, online help, database access, and much more.</p><p>  1.2 WHY USE WXWIDGETS?</p>

9、;<p>  One area where wxWidgets differs from many other frameworks, such as MFC or OWL, is its multi-platform nature. wxWidgets has an Application Programming Interface (API) that is the same, or very nearly the s

10、ame, on all supported platforms. This means that you can write an application on</p><p>  Windows, for example, and with very few changes (if any) recompile it on Linux or Mac OS X. This has a huge cost bene

11、fit compared with completely rewriting an application for each platform, and it also means that you do not need to learn a different API for each platform. Furthermore, it helps to</p><p>  future-proof your

12、 applications. As the computing landscape changes, wxWidgets changes with it, allowing your application to be ported to the latest and greatest systems supporting the newest features.</p><p>  Another distin

13、guishing feature is that wxWidgets provides a native look and feel. Some frameworks use the same widget code running on all platforms, perhaps with a theme makeover to simulate each platform’s native appearance. By contr

14、ast, wxWidgets uses the native widgets wherever possible (and its own widget set in other cases) so that not only does the application look native on the major platforms, but it actually is native. This is incredibly imp

15、ortant for user acceptance because even small,</p><p>  Figure 1-1 StoryLines on Windows</p><p>  It’s recognizably a Windows application, with GUI elements such as tabs, scrollbars, and drop-do

16、wn lists conforming to the current Windows theme. Similarly, Figure 1-2 shows StoryLines as a Mac OS X application, with the expected Aqua look and feel. There is no menu bar attached to the StoryLines window because it

17、follows the Mac OS convention of showing the current window’s menu bar at the top of the screen.</p><p>  Figure 1-2 StoryLines on Mac OS X</p><p>  Finally, Figure 1-3 shows StoryLines as a GTK

18、+ application running on Red Hat Linux.</p><p>  Figure 1-3 StoryLines on Linux</p><p>  Why not just use Java? While Java is great for web-based applications,</p><p>  it’s not alw

19、ays the best choice for the desktop. In general, C++-based applications using wxWidgets are faster, have a more native look and feel, and are easier to install because they don’t rely on the presence of the Java virtual

20、machine. C++ also allows greater access to low-level functionality and is easier to integrate with existing C and C++ code. For all these reasons, very few of the popular desktop applications that you use today are built

21、 with Java. wxWidgets allows you to deliver the </p><p>  wxWidgets is an open source project. Naturally, this means that it costs nothing to use wxWidgets (unless you feel like generously donating to the pr

22、oject!), but it also has important philosophical and strategic significance. Open source software has a habit of outlasting its proprietary equivalents. As a developer using wxWidgets, you know that the code you rely on

23、will never disappear. You can always fix any problems yourself by changing the source code. It can also be a lot more fun to take p</p><p>  projects tend to be there because they love what they’re doing and

24、 can’t wait to share their knowledge, whereas corporate support staff members are not always so idealistically motivated. When you use wxWidgets, you tap into an astonishing talent pool, with contributors from a wide ran

25、ge of backgrounds. Many aspects of application development that you might otherwise have to laboriously code yourself have been encapsulated by these developers in easyto- use classes that you can plug into your co</p

26、><p>  wxWidgets has wide industry support, or to use a popular buzzword, mindshare. The list of users includes AOL, AMD, CALTECH, Lockheed Martin, NASA, the Open Source Applications Foundation, Xerox, and many

27、 others. wxWidgets encompasses the whole spectrum of users, from single developer software outfits to large corporations, from computer science departments</p><p>  to medical research groups, and from ecolo

28、gical research to the telecommunications industry. It’s also used by a myriad of open source projects, such as the Audacity audio editor and the pgAdmin III database design and management system.</p><p>  Pe

29、ople use wxWidgets for many different reasons, whether simply as an elegant MFC replacement on a single platform, or to allow them to move easily from (say) Microsoft Windows to Unix and Mac OS X. wxWidgets is addressing

30、 the challenges of mobile platforms, too, with ports for embedded Linux, Microsoft Pocket PC, and (soon) Palm OS.</p><p>  1.3 A BRIEF HISTORY OF WXWIDGETS</p><p>  The wxWidgets project started

31、 life in 1992 when Julian Smart was working at the University of Edinburgh on a diagramming tool called Hardy. He didn’t want to choose between deploying it either on Sun workstations or PCs, so he decided to use a cross

32、-platform framework. Because the range of existing cross-platform frameworks was limited, and the department didn’t have a budget for it anyway, there was little choice but to write his own. The university gave him permi

33、ssion to upload wxWidgets 1.0 t</p><p>  Over time, a small but enthusiastic community of wxWidgets users was established and a mailing list created. Contributions and fixes were sent in, including an Xt por

34、t by Markus Holzem. wxWidgets gradually picked up more and more users from all over the world: individuals, academics, government departments, and—most gratifying of all—corporate users who found that wxWidgets offered a

35、 better product and better support than the commercial products they had looked at or used.</p><p>  In 1997, a new wxWidgets 2 API was designed with help from Markus Holzem.Wolfram Gloger suggested that wxW

36、idgets should be ported to GTK+, the up-and-coming widget set being adopted for the GNOME desktop environment. Robert Roebling became the lead developer for wxGTK, which is now the main Unix/Linux port of wxWidgets. In 1

37、998, the Windows and GTK+ ports were merged and put under CVS control. Vadim Zeitlin joined the project to contribute huge amounts of design and code, and Stefan Csomor start</p><p>  1999 saw the addition o

38、f Vaclav Slavik’s impressive wxHTML classes and the HTML-based help viewer. In 2000, SciTech, Inc. sponsored initial development of wxUniversal, wxWidgets’s own set of widgets for use on platforms A Brief History of wxWi

39、dgets 5 that have no widget set of their own. wxUniversal was first used in SciTech’s port to MGL, their low-level graphics layer.</p><p>  In 2002, Julian Smart and Robert Roebling added the wxX11 port usin

40、g the wxUniversal widgets. Requiring only Unix and X11, wxX11 is suitable for any Unix environment and can be used in fairly low-spec systems.</p><p>  In July 2003, wxWidgets started running on Windows CE,

41、and Robert Roebling demonstrated wxGTK applications running on the GPE embedded Linux platform.</p><p>  In 2004, wxWidgets was renamed from the original moniker “wxWindows,” after objections from Microsoft

42、based on its Windows trademark.</p><p>  Also during 2004, Stefan Csomor and a host of other contributors completely revamped wxMac for OS X, significantly improving the appearance and functionality of OS X

43、applications. A port using Cocoa was also steadily improved, led by David Elliot, and William Osborne won our challenge to deliver an embryonic Palm OS 6 port that supports the wxWidgets “minimal” sample. Version 2.6 was

44、 released in April 2005, incorporating major improvements to all ports.</p><p>  Future plans for wxWidgets include</p><p>  ·A package management tool, to make it easier to integrate third

45、-party components</p><p>  ·Improved support for embedded applications</p><p>  ·Alternative event handling mechanisms</p><p>  ·Enhanced controls, such as a combined

46、 tree and list control</p><p>  ·wxHTML 2, with full web capabilities on all platforms</p><p>  ·Further compatibility with standards such as STL</p><p>  ·A full Pal

47、m OS port</p><p>  1.4 THE WXWIDGETS COMMUNITY</p><p>  The wxWidgets community is a vibrant one, with two mailing lists: wx-users (for users) and wx-dev (for contributors). The web site has new

48、s, articles, and links to releases, and there is also the wxWidgets “Wiki,” a set of web pages where everyone can add information. A forum is also available for developers and users alike. Here’s a list of the web addres

49、ses for these resources:</p><p>  ·http://www.wxwidgets.org: the wxWidgets home page</p><p>  ·http://lists.wxwidgets.org: the mailing list archives</p><p>  ·http://

50、wiki.wxwidgets.org: the wxWidgets Wiki</p><p>  ·http://www.wxforum.org: the wxWidgets forum</p><p>  As with most open source projects, wxWidgets is developed using a CVS repository, a sou

51、rce management system that keeps track of code history. In order to prevent a chaotic free-for-all, a small number of developers have write access to CVS, and others can contribute by posting bug reports and patches (cur

52、rently handled by SourceForge’s trackers). Development occurs on two main branches: the “stable” branch, where only binary-compatible bug fixes are allowed, and the “development” branch (CVS he</p><p>  the

53、source from the appropriate branch by anonymous CVS. </p><p>  Decisions about API changes and other technical issues are made by consensus, usually by discussion on the wx-dev list. As well as the main wxWi

54、dgets community, many projects have spun off and enjoy their own communities— for example wxPython and wxPerl (see Appendix E, “Third-Party Tools for wxWidgets”).</p><p>  1.5WXWIDGETS AND OBJECT-ORIENTED PR

55、OGRAMMING</p><p>  Like all modern GUI frameworks, wxWidgets benefits from heavy use of objectoriented programming concepts. Each window is represented as a C++ object; these objects have well-defined behavi

56、or, and can receive and react to events. What the user sees is the visual manifestation of this interacting system of objects. Your job as a developer is to orchestrate these objects’ collective behavior, a task made eas

57、ier by the default behaviors that wxWidgets implements for you.</p><p>  Of course, it’s no coincidence that object-oriented programming and GUIs mesh well—they grew up together. The object-oriented language

58、 Smalltalk designed by Alan Kay and others in the 1970s was an important milestone in GUI history, making innovations in user interface technology as well as language design, and although wxWidgets uses a different langu

59、age and API, the principles employed are broadly the same.</p><p>  1.6 LICENSE CONSIDERATIONS</p><p>  The wxWidgets license (officially, the “wxWindows License” for legal and historical reason

60、s) is L-GPL with an exception clause. You can read the license files in detail on the web site or in the docs directory of the distribution, but in summary, you can use wxWidgets for commercial or free software with no r

61、oyalty charge. You can link statically or dynamically to the wxWidgets library. If you make changes to the wxWidgets source code, you are obliged to make these freely available. You do not h</p><p>  librari

62、es. </p><p>  The source code that accompanies this book is provided under the wxWindows License.</p><p>  1.7 THE WXWIDGETS ARCHITECTURE</p><p>  Table 1-1 shows the four conceptua

63、l layers: the wxWidgets public API, each major port, the platform API used by that port, and finally the underlying operating system.</p><p>  Table 1-1 wxWidgets Ports</p><p>  The following ar

64、e the main wxWidgets ports that exist at the time of writing.</p><p>  1.7.1 wxMSW</p><p>  This port compiles and runs on all 32-bit and 64-bit variants of the Microsoft Windows operating syste

65、m, including Windows 95,Windows 98,Windows ME, Windows NT, Windows 2000, Windows XP and Windows 2003. It can also be compiled to use Winelib under Linux, and has a configuration that works on Windows CE (see “wxWinCE”).

66、wxMSW can be configured to use the</p><p>  wxUniversal widgets instead of the regular Win32 ones.</p><p>  1.7.2 wxGTK</p><p>  wxWidgets for GTK+ can use versions 1.x or 2.x of th

67、e GTK+ widget set, on any Unix variant that supports X11 and GTK+ (for example, Linux, Solaris, HP-UX, IRIX, FreeBSD, OpenBSD, AIX, and others). It can also run on embedded platforms with sufficient resources—for example

68、, under the GPE Palmtop Environment (see Figure 1-4). wxGTK is the recommended port for Unixbased systems. </p><p>  Figure 1-4 The wxWidgets “Life!” demo under GPE on an iPAQ PDA</p><p>  1.7.3

69、wxX11</p><p>  wxWidgets for X11 uses the wxUniversal widget set and runs directly on Xlib with no native widget set. This makes the port suitable for embedded systems, but it can also be used for desktop ap

70、plications where it is undesirable to link with GTK+. This is supported on any Unix system running X11. wxX11 is not as mature as the wxGTK port. Figure 1-5 shows the Life! demo compiled under wxX11 and running on Famili

71、ar Linux / TinyX on an iPAQ PDA.</p><p>  Figure 1-5 The wxWidgets “Life!” demo running on embedded wxX11</p><p>  1.7.4wxMotif</p><p>  This port can use Motif, OpenMotif, or Lesst

72、if on most Unix systems. Sun Microsystems is putting its weight behind GNOME and GTK+, so Motif is no longer an attractive option for most developers and users.</p><p>  1.7.5 wxMac</p><p>  wxM

73、ac targets Mac OS 9 (from 9.1 upwards) and Mac OS X (from 10.2.8 upwards). For Mac OS 9 builds, you need the Metrowerks CodeWarrior tools, and for Mac OS X, you can use either Metrowerks CodeWarrior or Apple tools. When

74、using Apple’s tools, you should use Xcode 1.5 or higher, or—if you are just using command line tools—GCC 3.3 or higher.</p><p>  1.7.6 wxCocoa</p><p>  A port in progress, this targets the Cocoa

75、 API of Mac OS X. Although the functionality of Carbon and Cocoa is similar, this port has the potential for supporting GNUStep running on platforms other than a Mac.</p><p>  1.7.7 wxWinCE</p><p&

76、gt;  The Windows CE port encompasses various SDKs based on the Windows CE platform, including Pocket PC and Smartphone. The bulk of this port consists of the wxMSW Win32 port, with some omissions and additions for the sm

77、aller platform. Figure 1-6 shows the wxWidgets Life! demo running on the Pocket PC 2003 emulator. Figure 1-7 shows four screens from the wxWidgets dialog demo running on Smartphone 2003 with a 176 ??220 pixel display. Us

78、er interface adaptations done by wxWidgets for this restricted pl</p><p>  Figure 1-6 The wxWidgets “Life!” demo on Pocket PC 2003</p><p>  Figure 1-7 The wxWidgets “dialogs” demo on Smartphone

79、2003</p><p>  Figure 1-8 A wxWidgets sample under Palm OS 6</p><p>  1.7.8 wxPalmOS</p><p>  This is a port to Palm OS 6 (Cobalt). At the time of writing, the port is in its infancy

80、 but can be used to compile and run a simple sample in the Palm OS 6 simulator (see Figure 1-8).</p><p>  1.7.9 wxOS2</p><p>  wxOS2 is a Presentation Manager port for OS/2 or eComStation.</p

81、><p>  1.7.10 wxMGL</p><p>  This port targets the MGL low-level graphics layer from SciTech Software, Inc., and uses the wxUniversal widget set.</p><p>  1.7.11Internal Organization&l

82、t;/p><p>  Internally, the wxWidgets code base is broadly separated into six layers:</p><p>  1. Common code is used in all ports. It includes data structure classes, run-time type information, and

83、 the base classes, such as wxWindowBase, which are used to factor out code common to all implementations of a class.</p><p>  2. Generic code implements advanced widgets independently of any platform, allowi

84、ng emulation of controls and other functionality not present on a given platform. wxWizard and wxCalendarCtrl are examples of generic controls.</p><p>  3. wxUniversal is a set of basic widgets for those pla

85、tforms that do not have their own native widget set, such as bare X11 and MGL. </p><p>  4. Platform-specific code implements classes using native functionality. An example of platform-specific code is the w

86、xMSW implementation of wxTextCtrl wrapping the Win32 edit control. </p><p>  5. Contributed code exists in a separate hierarchy named contrib and includes non-essential but useful classes such as wxStyledTex

87、tCtrl. </p><p>  6. Third-party code comprises libraries that were developed independently of wxWidgets but are used to implement important features. Examples of third-party code include the JPEG, Zlib, PNG,

88、 and Expat libraries.</p><p>  Each port takes what it needs from these layers to implement the wxWidgets API. How does wxWidgets know which classes to use when you’re compiling your application? When you in

89、clude a wxWidgets header file, such as wx/textctrl.h, you’re actually including a platform-specific file such as wx/msw/textctrl.h, due to directives in wx/textctrl.h that conditionally include the appropriate declaratio

90、ns. You then link your application against a library that has been compiled with suitable settings for t</p><p>  Note that although wxWidgets is a wrapper around each native API, you are not prevented from

91、writing platform-specific code in that native API if you need to, although this is seldom necessary.</p><p>  1.8 SUMMARY</p><p>  In this chapter, we’ve established what wxWidgets is, described

92、 a little of its history, summarized the available ports, and taken a brief look at how the library is organized internally. </p><p>  wxWidgets技術簡介</p><p>  在這篇文章中,我們會回答這樣一些基本的問題:wxWidgets是什么,它

93、和別的類似的開發(fā)庫有什么不同。我們還會大概說一下這個項目的歷史,以及wxWidgets社區(qū)的工作,它采用的許可協(xié)議,它的體系架構以及目前擁有的各種版本等。</p><p>  1.1 什么是wxWidgets</p><p>  wxWidgets是一個給程序員使用的開發(fā)包,這個開發(fā)包用來開發(fā)用于桌面電腦或者移動設備的GUI(圖形用戶界面,下同)應用程序。它提供了一個編程框架,作了很多底層

94、的工作以便給應用程序及其控件提供默認的行為。wxWidgets庫給程序員提供了大量的類,這些類支持很多方法(方法是C++中的關鍵詞)以供其使用,程序員可以通過重載這些方法來實現(xiàn)定制的行為. 一個典型GUI程序所作的事情包括: 顯示一個包含各種控件的窗口,在窗口中繪制特定的圖形或者圖像,響應來自鼠標,鍵盤以及其它輸入設備的輸入,和其它的進程通信,調(diào)用別的應用程序等,wxWidgets所做的事情,就是讓程序員可以通過更簡單的手段來實現(xiàn)所有這

95、些當代應用程序的通用特性.</p><p>  雖然wxWidgets經(jīng)常被打上圖形界面程序開發(fā)的標簽,但是它在應用程序開發(fā)的其它方面也提供了很多支持,比如:文件和流操作,多線程,程序設置,進程間通訊,在線幫助,數(shù)據(jù)庫訪問等. 這樣作的目的是為了讓使用wxWidgets編寫的程序的各個部分都可以是跨平臺的,而不僅僅是GUI相關的部分.</p><p>  1.2 為什么選擇wxWidget

96、s?</p><p>  wxWidgets和其它類似的GUI庫(比如MFC或者OWL)的最本質的區(qū)別在于:它是跨平臺的. wxWidgets提供的API函數(shù)在它支持的所有平臺上都是相同或者至少是非常相近的. 這意味著你可以通過它編寫一個在Windows上運行的程序,這個程序不需要經(jīng)過任何改動(或者只需要很少的改動,這種情況并不常見),只需要通過重新編譯,就可以在Linux或者Mac OSX系統(tǒng)上運行. 比起為另

97、外的平臺從頭編寫代碼,這顯然是很大的優(yōu)勢. 另外一個附帶的好處就是: 你不需要重新學習那個平臺的API(應用程序編程接口,下同)。而且,你的程序可能在將來很長時間仍然不會過時,因為隨著計算機科技的演進,wxWidgets也將會進行相應的演進,這樣你的程序將會很方便的移植到將來的最新的操作系統(tǒng)以支持最新的特性。</p><p>  另外一個與眾不同的地方在于,wxWidgets可以給你的應用程序提供和當前系統(tǒng)平臺上

98、其它應用程序非常相似的外觀和操控手段。一些其它的可以跨平臺的開發(fā)框架在不同的平臺上使用同樣的窗口組件代碼,而通過類似窗口主題這樣的方式來模擬本地觀感。wxWidgets則盡可能的使用本地的窗口控件(當然wxWidgets也提供自己的控件集,這是另外一個話題了),所以wxWidgets的程序不只是看上去象是當前系統(tǒng)上的原生程序,它實際上就是原生程序。對于使用這些應用程序的用戶來說,本地觀感是非常重要的,因為和本地操作系統(tǒng)界面標準的任何一點

99、細微的甚至幾乎是難以察覺的不同,都會讓用戶產(chǎn)生避而遠之的想法。</p><p>  讓我們來舉例說明。下圖演示了一個叫做StoryLines的小程序運行在Windows XP上的樣子:</p><p>  圖1-1 StoryLines程序在Windows平臺上的樣子</p><p>  正象大家看到的那樣,這是一個典型的Windows應用程序,有典型的Window

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論