apptrait.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: apptrait.h
  3. // Purpose: interface of wxAppTraits
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxAppTraits
  9. The wxAppTraits class defines various configurable aspects of a wxApp.
  10. You can access it using wxApp::GetTraits() function and you can create your
  11. own wxAppTraits overriding the wxApp::CreateTraits() function.
  12. Note that wxAppTraits is an abstract class since it contains many
  13. pure virtual functions.
  14. In fact, by default, wxWidgets creates a @c wxConsoleAppTraits object for
  15. console applications (i.e. those applications linked against wxBase library
  16. only - see the @ref page_libs page) and a @c wxGUIAppTraits object for GUI
  17. applications.
  18. Both these classes are derived by wxAppTraits and represent concrete
  19. implementation of the wxAppTraits interface.
  20. @library{wxbase}
  21. @category{cfg}
  22. @see @ref overview_app, wxApp
  23. */
  24. class wxAppTraits
  25. {
  26. public:
  27. /**
  28. Called by wxWidgets to create the default configuration object for the
  29. application. The default version creates a registry-based wxRegConfig
  30. class under MSW and wxFileConfig under all other platforms.
  31. The wxApp::GetAppName and wxApp::GetVendorName methods are used to
  32. determine the registry key or file name.
  33. */
  34. virtual wxConfigBase* CreateConfig();
  35. /**
  36. Used by wxWidgets to create the main event loop used by wxApp::OnRun().
  37. The default implementation of this method in wxGUIAppTraits returns the
  38. usual platform-specific GUI event loop. The version in wxConsoleAppTraits
  39. returns a console-specific event loop which can be used to handle timer
  40. and socket events in console programs under Unix and MSW or @NULL under
  41. the other platforms where console event loops are not supported yet.
  42. */
  43. virtual wxEventLoopBase *CreateEventLoop() = 0;
  44. /**
  45. Creates the global font mapper object used for encodings/charset mapping.
  46. */
  47. virtual wxFontMapper* CreateFontMapper() = 0;
  48. /**
  49. Creates a wxLog class for the application to use for logging errors.
  50. The default implementation returns a new wxLogGui class.
  51. @see wxLog
  52. */
  53. virtual wxLog* CreateLogTarget() = 0;
  54. /**
  55. Creates the global object used for printing out messages.
  56. */
  57. virtual wxMessageOutput* CreateMessageOutput() = 0;
  58. /**
  59. Returns the renderer to use for drawing the generic controls (return
  60. value may be @NULL in which case the default renderer for the current
  61. platform is used); this is used in GUI mode only and always returns @NULL
  62. in console.
  63. @note the returned pointer needs to be deleted by the caller.
  64. */
  65. virtual wxRendererNative* CreateRenderer() = 0;
  66. /**
  67. This method returns the name of the desktop environment currently
  68. running in a Unix desktop. Currently only "KDE" or "GNOME" are
  69. supported and the code uses the X11 session protocol vendor name
  70. to figure out, which desktop environment is running. The method
  71. returns an empty string otherwise and on all other platforms.
  72. */
  73. virtual wxString GetDesktopEnvironment() const = 0;
  74. /**
  75. Returns the wxStandardPaths object for the application.
  76. It's normally the same for wxBase and wxGUI except in the case of wxMac
  77. and wxCocoa.
  78. @note
  79. The returned reference is to a @c wxStandardPathsBase class but you
  80. can consider it to be equivalent to wxStandardPaths (which is documented).
  81. */
  82. virtual wxStandardPaths& GetStandardPaths();
  83. /**
  84. Returns the wxWidgets port ID used by the running program and eventually
  85. fills the given pointers with the values of the major and minor digits
  86. of the native toolkit currently used.
  87. The version numbers returned are thus detected at run-time and not compile-time
  88. (except when this is not possible e.g. wxMotif).
  89. E.g. if your program is using wxGTK port this function will return wxPORT_GTK
  90. and put in given pointers the versions of the GTK library in use.
  91. See wxPlatformInfo for more details.
  92. */
  93. virtual wxPortId GetToolkitVersion(int* major = NULL, int* minor = NULL) const = 0;
  94. /**
  95. Returns @true if @c fprintf(stderr) goes somewhere, @false otherwise.
  96. */
  97. virtual bool HasStderr() = 0;
  98. /**
  99. Returns @true if the library was built as wxUniversal.
  100. Always returns @false for wxBase-only apps.
  101. */
  102. virtual bool IsUsingUniversalWidgets() const = 0;
  103. /**
  104. Shows the assert dialog with the specified message in GUI mode or just prints
  105. the string to stderr in console mode.
  106. Returns @true to suppress subsequent asserts, @false to continue as before.
  107. */
  108. virtual bool ShowAssertDialog(const wxString& msg) = 0;
  109. };