⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 body.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
📖 第 1 页 / 共 3 页
字号:
more header files than would normally be the case. This means thatchanging a header file will cause more recompilations (in the case ofwxWidgets, everything needs to be recompiled since everything includes {\tt "wx.h"}!)A related problem is that for compilers that don't have precompiledheaders, including a lot of header files slows down compilationconsiderably. For this reason, you will find (in the commonX and Windows parts of the library) conditionalcompilation that under Unix, includes a minimal set of headers;and when using Visual C++, includes {\tt wx.h}. This should help providethe optimal compilation for each compiler, although it isbiased towards the precompiled headers facility availablein Microsoft C++.\section{File handling}\label{filehandling}When building an application which may be used under differentenvironments, one difficulty is coping with documents which may bemoved to different directories on other machines. Saving a file whichhas pointers to full pathnames is going to be inherently unportable. Oneapproach is to store filenames on their own, with no directoryinformation.  The application searches through a number of locallydefined directories to find the file. To support this, the class {\bfwxPathList} makes adding directories and searching for files easy, andthe global function {\bf wxFileNameFromPath} allows the application tostrip off the filename from the path if the filename must be stored.This has undesirable ramifications for people who have documents of thesame name in different directories.As regards the limitations of DOS 8+3 single-case filenames versusunrestricted Unix filenames, the best solution is to use DOS filenamesfor your application, and also for document filenames {\it if} the useris likely to be switching platforms regularly. Obviously this latterchoice is up to the application user to decide.  Some programs (such asYACC and LEX) generate filenames incompatible with DOS; the bestsolution here is to have your Unix makefile rename the generated filesto something more compatible before transferring the source to DOS.Transferring DOS files to Unix is no problem, of course, apart from EOLconversion for which there should be a utility available (such asdos2unix).See also the File Functions section of the reference manual fordescriptions of miscellaneous file handling functions.\chapter{Utilities and libraries supplied with wxWidgets}\label{utilities}\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%\setfooter{\thepage}{}{}{}{}{\thepage}%In addition to the core wxWidgets library, a number of furtherlibraries and utilities are supplied with each distribution.Some are under the 'contrib' hierarchy which mirrors thestructure of the main wxWidgets hierarchy. See also the 'utils'hierarchy. The first place to look for documentation aboutthese tools and libraries is under the wxWidgets 'docs' hierarchy,for example {\tt docs/htmlhelp/fl.chm}.For other user-contributed packages, please see the Contributions pageon the \urlref{wxWidgets Web site}{http://www.wxwidgets.org}.\begin{description}\itemsep=0pt\item[{\bf Helpview}]Helpview is a program for displaying wxWidgets HTMLHelp files. In many cases, you may wish to use the wxWidgets HTMLHelp classes from within your application, but this provides ahandy stand-alone viewer. See \helpref{wxHTML Notes}{wxhtml} for more details.You can find it in {\tt samples/html/helpview}.\item[{\bf Tex2RTF}]Supplied with wxWidgets is a utility called Tex2RTF for converting\rtfsp\LaTeX\ manuals HTML, MS HTML Help, wxHTML Help, RTF, and WindowsHelp RTF formats. Tex2RTF is used for the wxWidgets manuals and can be used independentlyby authors wishing to create on-line and printed manuals from the same\rtfsp\LaTeX\ source. Please see the separate documentation for Tex2RTF.You can find it under {\tt utils/tex2rtf}.\item[{\bf Helpgen}]Helpgen takes C++ header files and generates a Tex2RTF-compatibledocumentation file for each class it finds, using comments as appropriate.This is a good way to start a reference for a set of classes.Helpgen can be found in {\tt utils/HelpGen}.\item[{\bf Emulator}]Xnest-based display emulator for X11-based PDA applications. On somesystems, the Xnest window does not synchronise with the'skin' window. This program can be found in {\tt utils/emulator}.\item[{\bf XRC resource system}]This is the sizer-aware resource system, and usesXML-based resource specifications that can be generated by toolssuch as \urlref{wxDesigner}{http://www.roebling.de}.You can find this in {\tt src/xrc}, {\tt include/wx/xrc}, {\tt samples/xrc}.For more information, see the \helpref{XML-based resource system overview}{xrcoverview}.\item[{\bf Object Graphics Library}]OGL defines an API for applications that need to display objects connected by lines.The objects can be moved around and interacted with.You can find this in {\tt contrib/src/ogl}, {\tt contrib/include/wx/ogl}, and {\tt contrib/samples/ogl}.\item[{\bf Frame Layout library}]FL provides sophisticated pane dragging and docking facilities.You can find this in {\tt contrib/src/fl}, {\tt contrib/include/wx/fl}, and {\tt contrib/samples/fl}.\item[{\bf Gizmos library}]Gizmos is a collection of useful widgets and other classes. Classes include wxLEDNumberCtrl,wxEditableListBox, wxMultiCellCanvas.You can find this in {\tt contrib/src/gizmos}, {\tt contrib/include/wx/gizmos}, and {\tt contrib/samples/gizmos}.\item[{\bf Net library}]Net is a collection of very simple mail and web related classes. Currentlythere is only wxEmail, which makes it easy to send email messages via MAPI on Windows or sendmail on Unix.You can find this in {\tt contrib/src/net} and {\tt contrib/include/wx/net}.\item[{\bf Animate library}]Animate allows you to load animated GIFs and play them on a window. The library can be extendedto use other animation formats.You can find this in {\tt contrib/src/animate}, {\tt contrib/include/wx/animate}, and {\tt contrib/samples/animate}.\item[{\bf MMedia library}]Mmedia supports a variety of multimedia functionality. The status of this library is currently unclear.You can find this in {\tt contrib/src/mmedia}, {\tt contrib/include/wx/mmedia}, and {\tt contrib/samples/mmedia}.\item[{\bf Styled Text Control library}]STC is a wrapper around Scintilla, a syntax-highlighting text editor.You can find this in {\tt contrib/src/stc}, {\tt contrib/include/wx/stc}, and {\tt contrib/samples/stc}.\item[{\bf Plot}]Plot is a simple curve plotting library.You can find this in {\tt contrib/src/plot}, {\tt contrib/include/wx/plot}, and {\tt contrib/samples/plot}.\end{description}\chapter{Programming strategies}\label{strategies}\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%\setfooter{\thepage}{}{}{}{}{\thepage}%This chapter is intended to list strategies that may be useful whenwriting and debugging wxWidgets programs. If you have any good tips,please submit them for inclusion here.\section{Strategies for reducing programming errors}\label{reducingerrors}\subsection{Use ASSERT}\label{useassert}Although I haven't done this myself within wxWidgets, it is goodpractice to use ASSERT statements liberally, that check for conditions thatshould or should not hold, and print out appropriate error messages.These can be compiled out of a non-debugging version of wxWidgetsand your application. Using ASSERT is an example of `defensive programming':it can alert you to problems later on.\subsection{Use wxString in preference to character arrays}\label{usewxstring}Using wxString can be much safer and more convenient than using wxChar *.Again, I haven't practiced what I'm preaching, but I'm now trying to usewxString wherever possible. You can reduce the possibility of memoryleaks substantially, and it is much more convenient to use the overloadedoperators than functions such as strcmp. wxString won't add a significantoverhead to your program; the overhead is compensated for by easiermanipulation (which means less code).The same goes for other data types: use classes wherever possible.\section{Strategies for portability}\label{portability}\subsection{Use relative positioning or constraints}\label{userelativepositioning}Don't use absolute panel item positioning if you can avoid it. Different GUIs havevery differently sized panel items. Consider using the constraint system, although thiscan be complex to program.Alternatively, you could use alternative .wrc (wxWidgets resource files) on differentplatforms, with slightly different dimensions in each. Or space your panel items outto avoid problems.\subsection{Use wxWidgets resource files}\label{useresources}Use .xrc (wxWidgets resource files) where possible, because they can be easily changedindependently of source code.\section{Strategies for debugging}\label{debugstrategies}\subsection{Positive thinking}\label{positivethinking}It is common to blow up the problem in one's imagination, so that it seems to threatenweeks, months or even years of work. The problem you face may seem insurmountable:but almost never is. Once you have been programming for some time, you will be ableto remember similar incidents that threw you into the depths of despair. Butremember, you always solved the problem, somehow!Perseverance is often the key, even though a seemingly trivial problemcan take an apparently inordinate amount of time to solve. In the end,you will probably wonder why you worried so much. That's not to say itisn't painful at the time. Try not to worry -- there are many more importantthings in life.\subsection{Simplify the problem}\label{simplifyproblem}Reduce the code exhibiting the problem to the smallest program possiblethat exhibits the problem. If it is not possible to reduce a large andcomplex program to a very small program, then try to ensure your codedoesn't hide the problem (you may have attempted to minimize the problemin some way: but now you want to expose it).With luck, you can add a small amount of code that causes the programto go from functioning to non-functioning state. This should give a clueto the problem. In some cases though, such as memory leaks or wrongdeallocation, this can still give totally spurious results!\subsection{Use a debugger}\label{usedebugger}This sounds like facetious advice, but it is surprising how often peopledon't use a debugger. Often it is an overhead to install or learn how touse a debugger, but it really is essential for anything but the mosttrivial programs.\subsection{Use logging functions}\label{uselogging}There is a variety of logging functions that you can use in your program:see \helpref{Logging functions}{logfunctions}.Using tracing statements may be more convenient than using the debuggerin some circumstances (such as when your debugger doesn't support a lotof debugging code, or you wish to print a bunch of variables).\subsection{Use the wxWidgets debugging facilities}\label{usedebuggingfacilities}You can use wxDebugContext to check formemory leaks and corrupt memory: in fact in debugging mode, wxWidgets willautomatically check for memory leaks at the end of the program if wxWidgets is suitablyconfigured. Depending on the operating system and compiler, more or lessspecific information about the problem will be logged.You should also use \helpref{debug macros}{debugmacros} as part of a `defensive programming' strategy,scattering wxASSERTs liberally to test for problems in your code as early as possible. Forward thinkingwill save a surprising amount of time in the long run.See the \helpref{debugging overview}{debuggingoverview} for further information.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -