app.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/app.h
  3. // Purpose: wxApp class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_APP_H_
  11. #define _WX_APP_H_
  12. #include "wx/event.h"
  13. #include "wx/icon.h"
  14. class WXDLLIMPEXP_FWD_CORE wxFrame;
  15. class WXDLLIMPEXP_FWD_CORE wxWindow;
  16. class WXDLLIMPEXP_FWD_CORE wxApp;
  17. class WXDLLIMPEXP_FWD_CORE wxKeyEvent;
  18. class WXDLLIMPEXP_FWD_BASE wxLog;
  19. // Represents the application. Derive OnInit and declare
  20. // a new App object to start application
  21. class WXDLLIMPEXP_CORE wxApp : public wxAppBase
  22. {
  23. public:
  24. wxApp();
  25. virtual ~wxApp();
  26. // override base class (pure) virtuals
  27. virtual bool Initialize(int& argc, wxChar **argv);
  28. virtual void CleanUp();
  29. virtual void WakeUpIdle();
  30. virtual void SetPrintMode(int mode) { m_printMode = mode; }
  31. virtual int GetPrintMode() const { return m_printMode; }
  32. // implementation only
  33. void OnIdle(wxIdleEvent& event);
  34. void OnEndSession(wxCloseEvent& event);
  35. void OnQueryEndSession(wxCloseEvent& event);
  36. #if wxUSE_EXCEPTIONS
  37. virtual bool OnExceptionInMainLoop();
  38. #endif // wxUSE_EXCEPTIONS
  39. // MSW-specific from now on
  40. // ------------------------
  41. // this suffix should be appended to all our Win32 class names to obtain a
  42. // variant registered without CS_[HV]REDRAW styles
  43. static const wxChar *GetNoRedrawClassSuffix() { return wxT("NR"); }
  44. // get the name of the registered Win32 class with the given (unique) base
  45. // name: this function constructs the unique class name using this name as
  46. // prefix, checks if the class is already registered and registers it if it
  47. // isn't and returns the name it was registered under (or NULL if it failed)
  48. //
  49. // the registered class will always have CS_[HV]REDRAW and CS_DBLCLKS
  50. // styles as well as any additional styles specified as arguments here; and
  51. // there will be also a companion registered class identical to this one
  52. // but without CS_[HV]REDRAW whose name will be the same one but with
  53. // GetNoRedrawClassSuffix()
  54. //
  55. // the background brush argument must be either a COLOR_XXX standard value
  56. // or (default) -1 meaning that the class paints its background itself
  57. static const wxChar *GetRegisteredClassName(const wxChar *name,
  58. int bgBrushCol = -1,
  59. int extraStyles = 0);
  60. // return true if this name corresponds to one of the classes we registered
  61. // in the previous GetRegisteredClassName() calls
  62. static bool IsRegisteredClassName(const wxString& name);
  63. protected:
  64. int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
  65. public:
  66. // unregister any window classes registered by GetRegisteredClassName()
  67. static void UnregisterWindowClasses();
  68. #if wxUSE_RICHEDIT
  69. // initialize the richedit DLL of (at least) given version, return true if
  70. // ok (Win95 has version 1, Win98/NT4 has 1 and 2, W2K has 3)
  71. static bool InitRichEdit(int version = 2);
  72. #endif // wxUSE_RICHEDIT
  73. // returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
  74. // wasn't found at all
  75. static int GetComCtl32Version();
  76. // the same for shell32.dll: returns 400, 471, 500, 600, ... (4.70 not
  77. // currently detected)
  78. static int GetShell32Version();
  79. // the SW_XXX value to be used for the frames opened by the application
  80. // (currently seems unused which is a bug -- TODO)
  81. static int m_nCmdShow;
  82. protected:
  83. DECLARE_EVENT_TABLE()
  84. wxDECLARE_NO_COPY_CLASS(wxApp);
  85. DECLARE_DYNAMIC_CLASS(wxApp)
  86. };
  87. #ifdef __WXWINCE__
  88. // under CE provide a dummy implementation of GetComCtl32Version() returning
  89. // the value passing all ">= 470" tests (which are the only ones used in our
  90. // code currently) as commctrl.dll under CE 2.0 and later support comctl32.dll
  91. // functionality
  92. inline int wxApp::GetComCtl32Version()
  93. {
  94. return 471;
  95. }
  96. // this is not currently used at all under CE so it's not really clear what do
  97. // we need to return from here
  98. inline int wxApp::GetShell32Version()
  99. {
  100. return 0;
  101. }
  102. #endif // __WXWINCE__
  103. #endif // _WX_APP_H_